http://www.apache.org/licenses/LICENSE-2.0
-Modifications by Scott Gasch Copyright 2020-2022 also released under
+Modifications by Scott Gasch Copyright © 2020-2022 also released under
the Apache 2.0 license as required by the license (see above).
Unless required by applicable law or agreed to in writing, software
@timeout(10.0, use_signals=False, error_message="Timed out waiting for tplink.py")
-def tplink_command(command: str) -> bool:
+def tplink_command_wrapper(command: str) -> bool:
result = os.system(command)
signal = result & 0xFF
if signal != 0:
if not brief:
raw = ''
for b in encrypted_raw_request:
- raw += '%02X ' % b
+ raw += f'{b:02X} '
logger.debug('Sent raw: "%s"', raw)
# Note: 4 bytes of garbage (the key)
if not brief:
raw = ''
for b in raw_response:
- raw += '%02X ' % b
+ raw += f'{b:02X} '
logger.debug('Received raw: "%s"', raw)
- if '"err_code":0' not in decrypted_raw_response:
- if '"err_code": 0' not in decrypted_raw_response:
- logger.error("Did not see clean err_code in response?!")
- return (False, all_responses)
- logger.debug('All commands succeeded, returning True.')
+ if (
+ '"err_code":0' not in decrypted_raw_response
+ and '"err_code": 0' not in decrypted_raw_response
+ ):
+ logger.error("Did not see clean err_code in response?!")
+ return (False, all_responses)
+ logger.debug('All commands succeeded.')
return (True, all_responses)
except socket.error:
logger.error("Cound not connect to host %s:%s", ip, port)