36def run(command, env=None, shell=False, throw_on_error=True):
37 print(
"Running command: ", command)
38
39 p = subprocess.Popen(command,
40 stdout=subprocess.PIPE,
41 stderr=subprocess.PIPE,
42 env=env,
43 shell=shell,
44 universal_newlines=True)
45 (stdout, stderr) = p.communicate()
46 if throw_on_error and p.returncode != 0:
47 print(
"Failed to execute '%s'. Exit code: %s." %
48 (command, p.returncode),
49 file=sys.stderr)
50 print(
"stdout: ", stdout, file=sys.stderr)
51 print(
"stderr: ", stderr, file=sys.stderr)
52 raise Exception("Failed to execute %s." % command)
53 return (stdout, stderr, p.returncode)
54
55
def run(command, env=None, shell=False, throw_on_error=True)
def print(*args, **kwargs)