mirror of
https://github.com/esphome/esphome.git
synced 2024-12-22 13:34:54 +01:00
Another fix for Python 3
This commit is contained in:
parent
1e12cba176
commit
06cb7497c8
1 changed files with 4 additions and 2 deletions
|
@ -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:
|
||||
|
|
Loading…
Reference in a new issue