summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEugene Triguba <eugenetriguba@gmail.com>2020-07-17 11:36:49 -0500
committerEugene Triguba <eugenetriguba@gmail.com>2020-07-17 11:37:18 -0500
commit67ba60080203cfe3e4184936e93ca7cd64008739 (patch)
tree8a7e7d35fe1e021b75417c3fbe2b771bf97bfb6f
parentRefactor initialization test to test on each OS (diff)
downloadlirc-67ba60080203cfe3e4184936e93ca7cd64008739.zip
Minor docstring tweaks and prevent out of bounds error on socket error
-rw-r--r--lirc/lirc.py13
1 files changed, 5 insertions, 8 deletions
diff --git a/lirc/lirc.py b/lirc/lirc.py
index d59a076..373d06a 100644
--- a/lirc/lirc.py
+++ b/lirc/lirc.py
@@ -83,8 +83,7 @@ class Lirc:
See SOCKET COMMAND INTERFACE in https://www.lirc.org/html/lircd.html
for more information.
- :return: A LircResponse containing information on the command sent,
- whether it was successful, and any other data, if any was sent.
+ :return: a response object containing information on the command sent.
"""
if not command.endswith("\n"):
command += "\n"
@@ -134,15 +133,14 @@ class Lirc:
buffer += data.decode(self.__encoding)
return buffer
- except (socket.timeout, socket.error) as e:
- err = e.args[0]
- if err == "timed out":
+ except (socket.timeout, socket.error) as error:
+ if len(error.args) >= 1 and error.args[0] == "timed out":
raise LircSocketTimeoutError(
f"could not find any data on the socket after "
f"{self.__timeout} seconds, socket timed out."
)
else:
- raise LircSocketError(e)
+ raise LircSocketError(error)
def __parse_reply_packet(self, packet: str) -> LircResponse:
"""
@@ -150,8 +148,7 @@ class Lirc:
:param packet: The reply packet from lirc.
- :return: An LircResponse containing the command sent,
- whether it was successful, and any other data, if any was sent.
+ :return: a response object containing information on the command sent.
"""
lines = packet.split("\n")
current_index = 0