Run a command list of `args` in a subprocess. Print the output. Exit on error.
(args)
| 95 | |
| 96 | |
| 97 | def run_command(args): |
| 98 | """ |
| 99 | Run a command list of `args` in a subprocess. Print the output. Exit on |
| 100 | error. |
| 101 | """ |
| 102 | cmd = " ".join(args) |
| 103 | print() |
| 104 | print(f"Running command: {cmd}") |
| 105 | try: |
| 106 | output = subprocess.check_output(args, encoding="utf-8", shell=on_windows) |
| 107 | print(f"Success to run command: {cmd}") |
| 108 | print(output) |
| 109 | |
| 110 | except subprocess.CalledProcessError as cpe: |
| 111 | print(f"Failure to run command: {cmd}") |
| 112 | print(cpe.output) |
| 113 | sys.exit(128) |
| 114 | |
| 115 | |
| 116 | if __name__ == "__main__": |
no test coverage detected