diff options
author | Devaev Maxim <[email protected]> | 2020-05-29 04:16:20 +0300 |
---|---|---|
committer | Devaev Maxim <[email protected]> | 2020-05-29 04:30:37 +0300 |
commit | eb13da03be9f52954755930def2bfdf57fb6347c (patch) | |
tree | 5d1776e93e036610652fc9c42c1aabb2d84c443b /kvmd/apps | |
parent | 1c93f6a562d1c2106d148cebb128397989fb84fd (diff) |
refactoring
Diffstat (limited to 'kvmd/apps')
-rw-r--r-- | kvmd/apps/kvmd/streamer.py | 18 |
1 files changed, 4 insertions, 14 deletions
diff --git a/kvmd/apps/kvmd/streamer.py b/kvmd/apps/kvmd/streamer.py index 357a46bb..7f527f69 100644 --- a/kvmd/apps/kvmd/streamer.py +++ b/kvmd/apps/kvmd/streamer.py @@ -36,6 +36,7 @@ import aiohttp from ...logging import get_logger from ... import aiotools +from ... import aioproc from ... import htclient from ... import gpio @@ -217,16 +218,10 @@ class Streamer: # pylint: disable=too-many-instance-attributes waiter_task = None async def get_info(self) -> Dict: - proc = await asyncio.create_subprocess_exec( - *[self.__cmd[0], "--version"], - stdout=asyncio.subprocess.PIPE, - stderr=asyncio.subprocess.DEVNULL, - preexec_fn=(lambda: signal.signal(signal.SIGINT, signal.SIG_IGN)), - ) - (stdout, _) = await proc.communicate() + version = (await aioproc.read_process([self.__cmd[0], "--version"], err_to_null=True))[1] return { "app": os.path.basename(self.__cmd[0]), - "version": stdout.decode(errors="ignore").strip(), + "version": version, } @aiotools.atomic @@ -329,12 +324,7 @@ class Streamer: # pylint: disable=too-many-instance-attributes ) for part in self.__cmd ] - self.__streamer_proc = await asyncio.create_subprocess_exec( - *cmd, - stdout=asyncio.subprocess.PIPE, - stderr=asyncio.subprocess.STDOUT, - preexec_fn=(lambda: signal.signal(signal.SIGINT, signal.SIG_IGN)), - ) + self.__streamer_proc = await aioproc.run_process(cmd) get_logger(0).info("Started streamer pid=%d: %s", self.__streamer_proc.pid, cmd) async def __kill_streamer_proc(self) -> None: |