mirror of
https://github.com/esphome/esphome.git
synced 2024-11-25 16:38:16 +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):
|
def receive_exactly(sock, amount, msg, expect, decode=True):
|
||||||
if decode:
|
if decode:
|
||||||
data = []
|
data = []
|
||||||
else:
|
elif IS_PY2:
|
||||||
data = ''
|
data = ''
|
||||||
|
else:
|
||||||
|
data = b''
|
||||||
|
|
||||||
try:
|
try:
|
||||||
data += recv_decode(sock, 1, decode=decode)
|
data += recv_decode(sock, 1, decode=decode)
|
||||||
|
@ -168,6 +170,8 @@ def perform_ota(sock, password, file_handle, filename):
|
||||||
if not password:
|
if not password:
|
||||||
raise OTAError("ESP requests password, but no password given!")
|
raise OTAError("ESP requests password, but no password given!")
|
||||||
nonce = receive_exactly(sock, 32, 'authentication nonce', [], decode=False)
|
nonce = receive_exactly(sock, 32, 'authentication nonce', [], decode=False)
|
||||||
|
if not IS_PY2:
|
||||||
|
nonce = nonce.decode()
|
||||||
_LOGGER.debug("Auth: Nonce is %s", nonce)
|
_LOGGER.debug("Auth: Nonce is %s", nonce)
|
||||||
cnonce = hashlib.md5(str(random.random()).encode()).hexdigest()
|
cnonce = hashlib.md5(str(random.random()).encode()).hexdigest()
|
||||||
_LOGGER.debug("Auth: CNonce is %s", cnonce)
|
_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.")
|
_LOGGER.warning("Couldn't auto-update local git copy of esphomelib.")
|
||||||
return
|
return
|
||||||
if IS_PY3:
|
if IS_PY3:
|
||||||
try:
|
stdout = stdout.decode('utf-8', 'backslashreplace')
|
||||||
stdout = stdout.encode('utf-8')
|
|
||||||
except Exception: # pylint: disable=broad-except
|
|
||||||
pass
|
|
||||||
safe_print(stdout.strip())
|
safe_print(stdout.strip())
|
||||||
|
|
||||||
|
|
||||||
|
@ -299,6 +296,7 @@ def gather_build_flags():
|
||||||
build_flags.add('-DESPHOMEYAML_USE')
|
build_flags.add('-DESPHOMEYAML_USE')
|
||||||
build_flags.add("-Wno-unused-variable")
|
build_flags.add("-Wno-unused-variable")
|
||||||
build_flags.add("-Wno-unused-but-set-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')
|
||||||
build_flags |= get_build_flags('REQUIRED_BUILD_FLAGS')
|
build_flags |= get_build_flags('REQUIRED_BUILD_FLAGS')
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue