From d85222ad80d0e426a4ba6a8069ddb664ff1f912d Mon Sep 17 00:00:00 2001 From: Franck Nijhof Date: Sat, 4 Apr 2020 20:02:50 +0200 Subject: [PATCH] Use byte literals instead of encode (#33633) --- homeassistant/components/actiontec/device_tracker.py | 6 +++--- homeassistant/components/graphite/__init__.py | 2 +- homeassistant/components/lannouncer/notify.py | 2 +- homeassistant/components/thomson/device_tracker.py | 4 ++-- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/homeassistant/components/actiontec/device_tracker.py b/homeassistant/components/actiontec/device_tracker.py index 302a8d56173..d9d4a4f2ea6 100644 --- a/homeassistant/components/actiontec/device_tracker.py +++ b/homeassistant/components/actiontec/device_tracker.py @@ -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 diff --git a/homeassistant/components/graphite/__init__.py b/homeassistant/components/graphite/__init__.py index bf34bc3ddea..104ad61e93c 100644 --- a/homeassistant/components/graphite/__init__.py +++ b/homeassistant/components/graphite/__init__.py @@ -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): diff --git a/homeassistant/components/lannouncer/notify.py b/homeassistant/components/lannouncer/notify.py index 9421eb16f51..2e5cb9b5600 100644 --- a/homeassistant/components/lannouncer/notify.py +++ b/homeassistant/components/lannouncer/notify.py @@ -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) diff --git a/homeassistant/components/thomson/device_tracker.py b/homeassistant/components/thomson/device_tracker.py index 1f3fda6cc72..05e7a49b625 100644 --- a/homeassistant/components/thomson/device_tracker.py +++ b/homeassistant/components/thomson/device_tracker.py @@ -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