19 loader = importlib.machinery.SourceFileLoader(modname, filename)
20 spec = importlib.util.spec_from_file_location(modname,
23 module = importlib.util.module_from_spec(spec)
27 loader.exec_module(module)
36def run(command, env=None, shell=False, throw_on_error=True):
37 print(
"Running command: ", command)
39 p = subprocess.Popen(command,
40 stdout=subprocess.PIPE,
41 stderr=subprocess.PIPE,
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),
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)