运行命令并打印输出
(cmd)
| 6 | |
| 7 | |
| 8 | def run_command(cmd): |
| 9 | """运行命令并打印输出""" |
| 10 | print(f"\n执行: {' '.join(cmd)}") |
| 11 | result = subprocess.run(cmd, capture_output=True, text=True) |
| 12 | if result.stdout: |
| 13 | print(result.stdout) |
| 14 | if result.stderr: |
| 15 | print(result.stderr, file=sys.stderr) |
| 16 | return result.returncode |
| 17 | |
| 18 | |
| 19 | def main(): |