Use byte literals instead of encode ()

pull/33652/head
Franck Nijhof 2020-04-04 20:02:50 +02:00 committed by GitHub
parent 39a01fcdc6
commit d85222ad80
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 7 additions and 7 deletions
homeassistant/components

View File

@ -99,11 +99,11 @@ class ActiontecDeviceScanner(DeviceScanner):
telnet.read_until(b"Password: ")
telnet.write((self.password + "\n").encode("ascii"))
prompt = telnet.read_until(b"Wireless Broadband Router> ").split(b"\n")[-1]
telnet.write("firewall mac_cache_dump\n".encode("ascii"))
telnet.write("\n".encode("ascii"))
telnet.write(b"firewall mac_cache_dump\n")
telnet.write(b"\n")
telnet.read_until(prompt)
leases_result = telnet.read_until(prompt).split(b"\n")[1:-1]
telnet.write("exit\n".encode("ascii"))
telnet.write(b"exit\n")
except EOFError:
_LOGGER.exception("Unexpected response from router")
return

View File

@ -104,7 +104,7 @@ class GraphiteFeeder(threading.Thread):
sock.settimeout(10)
sock.connect((self._host, self._port))
sock.sendall(data.encode("ascii"))
sock.send("\n".encode("ascii"))
sock.send(b"\n")
sock.close()
def _report_attributes(self, entity_id, new_state):

View File

@ -69,7 +69,7 @@ class LannouncerNotificationService(BaseNotificationService):
# Send message
_LOGGER.debug("Sending message: %s", cmd)
sock.sendall(cmd.encode())
sock.sendall("&@DONE@\n".encode())
sock.sendall(b"&@DONE@\n")
# Check response
buffer = sock.recv(1024)

View File

@ -98,9 +98,9 @@ class ThomsonDeviceScanner(DeviceScanner):
telnet.read_until(b"Password : ")
telnet.write((self.password + "\r\n").encode("ascii"))
telnet.read_until(b"=>")
telnet.write(("hostmgr list\r\n").encode("ascii"))
telnet.write(b"hostmgr list\r\n")
devices_result = telnet.read_until(b"=>").split(b"\r\n")
telnet.write("exit\r\n".encode("ascii"))
telnet.write(b"exit\r\n")
except EOFError:
_LOGGER.exception("Unexpected response from router")
return