diff options
Diffstat (limited to 'kvmd/aioproc.py')
-rw-r--r-- | kvmd/aioproc.py | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/kvmd/aioproc.py b/kvmd/aioproc.py index 4c503bca..65502d35 100644 --- a/kvmd/aioproc.py +++ b/kvmd/aioproc.py @@ -23,6 +23,7 @@ import asyncio import asyncio.subprocess import signal +import logging from typing import Tuple from typing import List @@ -46,6 +47,15 @@ async def read_process(cmd: List[str], err_to_null: bool=False) -> Tuple[asyncio return (proc, stdout.decode(errors="ignore").strip()) +async def log_process(cmd: List[str], logger: logging.Logger) -> asyncio.subprocess.Process: # pylint: disable=no-member + (proc, stdout) = await read_process(cmd) + if stdout: + log = (logger.info if proc.returncode == 0 else logger.error) + for line in stdout.split("\n"): + log("Console: %s", line) + return proc + + def ignore_sigint() -> None: signal.signal(signal.SIGINT, signal.SIG_IGN) |