From 06cb7497c8f65fe9389beae06aca70006e8f34a7 Mon Sep 17 00:00:00 2001 From: Otto Winter Date: Thu, 3 Jan 2019 17:09:28 +0100 Subject: [PATCH] Another fix for Python 3 --- esphomeyaml/espota2.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/esphomeyaml/espota2.py b/esphomeyaml/espota2.py index f329c07949..d70dbb929d 100755 --- a/esphomeyaml/espota2.py +++ b/esphomeyaml/espota2.py @@ -7,7 +7,7 @@ import time from esphomeyaml.core import EsphomeyamlError from esphomeyaml.helpers import resolve_ip_address, is_ip_address -from esphomeyaml.py_compat import IS_PY2 +from esphomeyaml.py_compat import IS_PY2, char RESPONSE_OK = 0 RESPONSE_REQUEST_AUTH = 1 @@ -68,7 +68,7 @@ def recv_decode(sock, amount, decode=True): data = sock.recv(amount) if not decode: return data - return [ord(x) for x in data] + return [char(x) for x in data] def receive_exactly(sock, amount, msg, expect, decode=True): @@ -136,6 +136,8 @@ def send_check(sock, data, msg): data = bytes(data) elif isinstance(data, int): data = bytes([data]) + elif isinstance(data, str): + data = data.encode('utf8') sock.sendall(data) except socket.error as err: