String override

This commit is contained in:
2017-07-11 17:39:47 +02:00
parent 4e27cc8b6e
commit 110097ec81
2 changed files with 10 additions and 6 deletions

View File

@ -52,8 +52,9 @@ def get_workspace_subdir(subdir):
def run(cmd, captureOutput=False, pty=False, debug=False, **kwargs):
"""Execute an arbitrary command on the system"""
if debug:
print(" ".join(cmd))
print(" ".join(cmd) if isinstance(cmd, list) else cmd)
stdin=subprocess.PIPE
kwargs['shell'] = False if isinstance(cmd, list) else True
if pty:
kwargs['stdin'] = sys.stdin
if captureOutput:
@ -62,4 +63,8 @@ def run(cmd, captureOutput=False, pty=False, debug=False, **kwargs):
return subprocess.check_call(cmd, **kwargs)
def run_docker(args, captureOutput=False, **kwargs):
return run(["docker"] + args, captureOutput=captureOutput, **kwargs)
if isinstance(args, list):
cmd = ["docker"] + args
else:
cmd = "docker " + args
return run(cmd, captureOutput=captureOutput, **kwargs)