From 815da05b29a9ec342a10958ad076d9c60b0adedb Mon Sep 17 00:00:00 2001 From: Otto Winter Date: Thu, 3 Jan 2019 19:54:36 +0100 Subject: [PATCH] Fix OTA Auth for Python 3 --- esphomeyaml/espota2.py | 6 +++++- esphomeyaml/writer.py | 6 ++---- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/esphomeyaml/espota2.py b/esphomeyaml/espota2.py index d70dbb929d..423fc6a5bd 100755 --- a/esphomeyaml/espota2.py +++ b/esphomeyaml/espota2.py @@ -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) diff --git a/esphomeyaml/writer.py b/esphomeyaml/writer.py index 25c8be609d..235f8078ce 100644 --- a/esphomeyaml/writer.py +++ b/esphomeyaml/writer.py @@ -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')