diff options
| author | Scott <[email protected]> | 2022-01-11 13:33:24 -0800 |
|---|---|---|
| committer | Scott <[email protected]> | 2022-01-11 13:33:24 -0800 |
| commit | b454ad295eb3024a238d32bf2aef1ebc3c496b44 (patch) | |
| tree | 89368a7cdad571da9e2c7297190fdce48eb3feb9 /smart_home/lights.py | |
| parent | d2478310649d51e14f8ece57651ca9d925d98793 (diff) | |
Start using warnings from stdlib.
Diffstat (limited to 'smart_home/lights.py')
| -rw-r--r-- | smart_home/lights.py | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/smart_home/lights.py b/smart_home/lights.py index e23569a..44b3634 100644 --- a/smart_home/lights.py +++ b/smart_home/lights.py @@ -11,6 +11,7 @@ import re import subprocess import sys from typing import Any, Dict, List, Optional, Tuple +import warnings from overrides import overrides import tinytuya as tt @@ -46,14 +47,18 @@ def tplink_light_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) + warnings.warn(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) + warnings.warn(msg) + logging_utils.hlog(msg) return False logger.debug(f'{command} succeeded.') return True |
