Run a command and handle errors.
(cmd, description="")
| 11 | from pathlib import Path |
| 12 | |
| 13 | def run_command(cmd, description=""): |
| 14 | """Run a command and handle errors.""" |
| 15 | if description: |
| 16 | print(f"\n🔄 {description}") |
| 17 | print(f"Running: {' '.join(cmd)}") |
| 18 | |
| 19 | try: |
| 20 | result = subprocess.run(cmd, check=True, capture_output=True, text=True) |
| 21 | print("✅ Success!") |
| 22 | if result.stdout: |
| 23 | print(result.stdout) |
| 24 | return True |
| 25 | except subprocess.CalledProcessError as e: |
| 26 | print(f"❌ Failed with exit code {e.returncode}") |
| 27 | if e.stdout: |
| 28 | print("STDOUT:", e.stdout) |
| 29 | if e.stderr: |
| 30 | print("STDERR:", e.stderr) |
| 31 | return False |
| 32 | |
| 33 | def check_dependencies(): |
| 34 | """Check if test dependencies are installed.""" |