Initial MVP commits #1
@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
import asyncio
|
import asyncio
|
||||||
import logging
|
import logging
|
||||||
|
import subprocess
|
||||||
from contextlib import AsyncExitStack
|
from contextlib import AsyncExitStack
|
||||||
from typing import Any, Dict, Set
|
from typing import Any, Dict, Set
|
||||||
|
|
||||||
@ -49,11 +50,19 @@ async def screen_state_mqtt_handler(messages):
|
|||||||
"""Screen state handler, reacts on presence messages."""
|
"""Screen state handler, reacts on presence messages."""
|
||||||
log = logging.getLogger(__name__)
|
log = logging.getLogger(__name__)
|
||||||
async for message in messages:
|
async for message in messages:
|
||||||
log.info(
|
payload = message.payload.decode()
|
||||||
"screen sate message on topic %s: %s",
|
log.info("screen sate message on topic %s: %s", message.topic, payload)
|
||||||
message.topic,
|
if payload == "on":
|
||||||
message.payload.decode(),
|
cmd = ["xset", "dpms", "force", "on"]
|
||||||
)
|
log.info("motion detected, forcing screen state to on. CMD: %s", cmd)
|
||||||
|
result = subprocess.run(cmd, capture_output=True)
|
||||||
|
if result.returncode != 0:
|
||||||
|
log.error(
|
||||||
|
"nonzero return code: %s. stderr: %r, stdout: %r",
|
||||||
|
result.returncode,
|
||||||
|
result.stderr,
|
||||||
|
result.stdout,
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
async def cancel_tasks(tasks):
|
async def cancel_tasks(tasks):
|
||||||
|
|||||||
5
tox.ini
5
tox.ini
@ -1,5 +1,5 @@
|
|||||||
[tox]
|
[tox]
|
||||||
envlist = py37,security,lint,bundle
|
envlist = py37,security,lint
|
||||||
isolated_build = True
|
isolated_build = True
|
||||||
|
|
||||||
[testenv]
|
[testenv]
|
||||||
@ -14,6 +14,7 @@ deps = setuptools
|
|||||||
deps =
|
deps =
|
||||||
importlib_metadata
|
importlib_metadata
|
||||||
pytest
|
pytest
|
||||||
|
pytest-asyncio
|
||||||
pytest-cov
|
pytest-cov
|
||||||
pdbpp
|
pdbpp
|
||||||
commands =
|
commands =
|
||||||
@ -29,7 +30,7 @@ commands =
|
|||||||
deps =
|
deps =
|
||||||
bandit
|
bandit
|
||||||
commands =
|
commands =
|
||||||
bandit {envsitepackagesdir}/hasskiosk -r
|
bandit {toxinidir}/src/hasskiosk -r
|
||||||
|
|
||||||
[testenv:lint]
|
[testenv:lint]
|
||||||
deps =
|
deps =
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user