Run a command and handle errors.
(command, description)
| 9 | |
| 10 | |
| 11 | def run_command(command, description): |
| 12 | """Run a command and handle errors.""" |
| 13 | print(f"🔄 {description}...") |
| 14 | try: |
| 15 | result = subprocess.run(command, shell=True, check=True, capture_output=True, text=True) |
| 16 | print(f"✅ {description} completed successfully") |
| 17 | return True |
| 18 | except subprocess.CalledProcessError as e: |
| 19 | print(f"❌ {description} failed: {e}") |
| 20 | print(f"Error output: {e.stderr}") |
| 21 | return False |
| 22 | |
| 23 | |
| 24 | def main(): |