Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def write(self, command):
"""Write a preformatted command line to lircd"""
os.write(self.socket.fileno(), command)
# Read the response packet lircd sends back, everything between BEGIN and END
response = []
while self.socketf.readline().strip() != "BEGIN":
pass
while True:
line = self.socketf.readline().strip()
if line == "END":
break
response.append(line)
if response[0].strip() != command.strip():
raise LircTransmitError("Command was not echoed")
if response[1] != "SUCCESS":
raise LircTransmitError(response[-1])
# Read the response packet lircd sends back, everything between BEGIN and END
response = []
while self.socketf.readline().strip() != "BEGIN":
pass
while True:
line = self.socketf.readline().strip()
if line == "END":
break
response.append(line)
if response[0].strip() != command.strip():
raise LircTransmitError("Command was not echoed")
if response[1] != "SUCCESS":
raise LircTransmitError(response[-1])