def run_cmd(cmd, quiet=False):
if not quiet:
logging.info('command: {}'.format(cmd))
# use shlex to keep quoted substrings
result = run(shlex.split(cmd), stdout=PIPE, stderr=PIPE)
stdout = result.stdout.strip().decode()
stderr = result.stderr.strip().decode()
if stdout and not quiet:
logging.debug(stdout)
if stderr and not quiet:
logging.warning(stderr)
return result.stdout.strip()
评论列表
文章目录