Change locking boundaries for shared dict. Add a unit test.
[python_utils.git] / smart_home / outlets.py
index 8fd09487a48b5c49478bb5d84b91d481dc36adfc..c079cfd09d9cbbfbb8595379770ebc1c8d7497ae 100644 (file)
@@ -48,14 +48,16 @@ def tplink_outlet_command(command: str) -> bool:
     result = os.system(command)
     signal = result & 0xFF
     if signal != 0:
-        logger.warning(f'{command} died with signal {signal}')
-        logging_utils.hlog("%s died with signal %d" % (command, signal))
+        msg = f'{command} died with signal {signal}'
+        logger.warning(msg)
+        logging_utils.hlog(msg)
         return False
     else:
         exit_value = result >> 8
         if exit_value != 0:
-            logger.warning(f'{command} failed, exited {exit_value}')
-            logging_utils.hlog("%s failed, exit %d" % (command, exit_value))
+            msg = f'{command} failed, exited {exit_value}'
+            logger.warning(msg)
+            logging_utils.hlog(msg)
             return False
     logger.debug(f'{command} succeeded.')
     return True