diff options
author | Alexey 'Cluster' Avdyukhin <clusterrr@clusterrr.com> | 2021-12-02 11:53:10 +0300 |
---|---|---|
committer | Alexey 'Cluster' Avdyukhin <clusterrr@clusterrr.com> | 2021-12-02 11:53:10 +0300 |
commit | 80ff4deef6db5b4f2847c762039d5c6d91a8e561 (patch) | |
tree | 1df0700c728fb143e53e44a6893cd487d839435a /devices | |
parent | cccba5da29000cbba8e9f927ba01b978b735eeaa (diff) |
Logging in example
Diffstat (limited to 'devices')
-rw-r--r-- | devices/pc.py | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/devices/pc.py b/devices/pc.py index ebd85d4..05640b8 100644 --- a/devices/pc.py +++ b/devices/pc.py @@ -1,5 +1,8 @@ +import logging import subprocess +logger = logging.getLogger() + def pc_query(capability_type, instance): if capability_type == "devices.capabilities.on_off": p = subprocess.run(["ping", "-c", "1", "192.168.0.2"], stdout=subprocess.PIPE) @@ -9,7 +12,9 @@ def pc_query(capability_type, instance): def pc_action(capability_type, instance, value, relative): if capability_type == "devices.capabilities.on_off": if value: + logger.debug("sending WoL to PC") subprocess.run(["wakeonlan", "-i", "192.168.0.255", "00:11:22:33:44:55"]) else: + logger.debug("sending shutdown command to PC") subprocess.run(["sh", "-c", "echo shutdown -h | ssh clust@192.168.0.2"]) return "DONE" |