-def run(command, msg="", check=False, log=True, console=False):
+def run(command, msg=u"", check=True, log=False, console=False):
"""Wrapper around subprocess.check_output that can tolerates nonzero RCs.
Stderr is redirected to stdout, so it is part of output
"""Wrapper around subprocess.check_output that can tolerates nonzero RCs.
Stderr is redirected to stdout, so it is part of output
try:
output = subprocess.check_output(command, stderr=subprocess.STDOUT)
except subprocess.CalledProcessError as err:
output = err.output
ret_code = err.returncode
if check:
try:
output = subprocess.check_output(command, stderr=subprocess.STDOUT)
except subprocess.CalledProcessError as err:
output = err.output
ret_code = err.returncode
if check:
- raise RuntimeError(MESSAGE_TEMPLATE.format(
- com=err.cmd, ret=ret_code, out=output))
+ raise RuntimeError(
+ MESSAGE_TEMPLATE.format(com=err.cmd, ret=ret_code, out=output)
+ )