2020-07-09 11:57:54 +00:00
|
|
|
import subprocess
|
|
|
|
|
|
|
|
|
2020-07-10 10:48:25 +00:00
|
|
|
def run_command(command, stdout=None, stdin=None, stderr=None):
|
2020-07-10 04:37:22 +00:00
|
|
|
stdout = stdout or subprocess.PIPE
|
|
|
|
stderr = stderr or subprocess.PIPE
|
2020-07-10 10:48:25 +00:00
|
|
|
process = subprocess.Popen(command, stdout=stdout, stdin=stdin, stderr=stderr)
|
2020-07-09 11:57:54 +00:00
|
|
|
out, error = process.communicate()
|
|
|
|
if process.returncode:
|
|
|
|
print("Something went wrong:")
|
|
|
|
print(f"return code: {process.returncode}")
|
|
|
|
print(f"stdout:\n{out}")
|
|
|
|
print(f"\nstderr:\n{error}")
|
|
|
|
exit(process.returncode)
|