mirror of
https://github.com/esphome/esphome.git
synced 2024-12-22 05:24:53 +01:00
Fix OTA Auth for Python 3
This commit is contained in:
parent
a2083fc901
commit
815da05b29
2 changed files with 7 additions and 5 deletions
|
@ -74,8 +74,10 @@ def recv_decode(sock, amount, decode=True):
|
|||
def receive_exactly(sock, amount, msg, expect, decode=True):
|
||||
if decode:
|
||||
data = []
|
||||
else:
|
||||
elif IS_PY2:
|
||||
data = ''
|
||||
else:
|
||||
data = b''
|
||||
|
||||
try:
|
||||
data += recv_decode(sock, 1, decode=decode)
|
||||
|
@ -168,6 +170,8 @@ def perform_ota(sock, password, file_handle, filename):
|
|||
if not password:
|
||||
raise OTAError("ESP requests password, but no password given!")
|
||||
nonce = receive_exactly(sock, 32, 'authentication nonce', [], decode=False)
|
||||
if not IS_PY2:
|
||||
nonce = nonce.decode()
|
||||
_LOGGER.debug("Auth: Nonce is %s", nonce)
|
||||
cnonce = hashlib.md5(str(random.random()).encode()).hexdigest()
|
||||
_LOGGER.debug("Auth: CNonce is %s", cnonce)
|
||||
|
|
|
@ -124,10 +124,7 @@ def update_esphomelib_repo():
|
|||
_LOGGER.warning("Couldn't auto-update local git copy of esphomelib.")
|
||||
return
|
||||
if IS_PY3:
|
||||
try:
|
||||
stdout = stdout.encode('utf-8')
|
||||
except Exception: # pylint: disable=broad-except
|
||||
pass
|
||||
stdout = stdout.decode('utf-8', 'backslashreplace')
|
||||
safe_print(stdout.strip())
|
||||
|
||||
|
||||
|
@ -299,6 +296,7 @@ def gather_build_flags():
|
|||
build_flags.add('-DESPHOMEYAML_USE')
|
||||
build_flags.add("-Wno-unused-variable")
|
||||
build_flags.add("-Wno-unused-but-set-variable")
|
||||
build_flags.add("-Wno-sign-compare")
|
||||
build_flags |= get_build_flags('required_build_flags')
|
||||
build_flags |= get_build_flags('REQUIRED_BUILD_FLAGS')
|
||||
|
||||
|
|
Loading…
Reference in a new issue