This commit is contained in:
Robert Martin
2020-01-27 23:11:13 +09:00
parent c2614e1ef5
commit 60ad6298df
6 changed files with 321 additions and 7 deletions
+21
View File
@@ -0,0 +1,21 @@
import asyncio
import logging
logger = logging.getLogger(__name__)
async def run_system_command(cmd):
proc = await asyncio.create_subprocess_shell(
cmd,
stdout=asyncio.subprocess.PIPE,
stderr=asyncio.subprocess.PIPE)
stdout, stderr = await proc.communicate()
logger.debug(f'[{cmd!r} exited with {proc.returncode}]')
if stdout:
logger.debug(f'[stdout]\n{stdout.decode()}')
if stderr:
logger.debug(f'[stderr]\n{stderr.decode()}')
return proc.returncode