Another fix for Python 3

This commit is contained in:
Otto Winter 2019-01-03 17:09:28 +01:00
parent 1e12cba176
commit 06cb7497c8
No known key found for this signature in database
GPG Key ID: DB66C0BE6013F97E
1 changed files with 4 additions and 2 deletions

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: