1
0
mirror of https://github.com/esphome/esphome.git synced 2025-09-04 04:12:23 +01:00

Another fix for Python 3

This commit is contained in:
Otto Winter
2019-01-03 17:09:28 +01:00
parent 1e12cba176
commit 06cb7497c8

View File

@@ -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: