feat: enhance command execution with error handling and add Ansible task for Docker repository checkout
Some checks failed
Nix Format Check / check-format (push) Failing after 38s
Some checks failed
Nix Format Check / check-format (push) Failing after 38s
This commit is contained in:
@ -5,6 +5,7 @@ import sys
|
||||
import subprocess
|
||||
import math
|
||||
import random
|
||||
import shutil
|
||||
try:
|
||||
import pyfiglet
|
||||
except ImportError:
|
||||
@ -79,15 +80,20 @@ def logo(continue_after=False):
|
||||
sys.exit(0)
|
||||
except Exception as e:
|
||||
printfe("red", f"Error displaying logo: {e}")
|
||||
|
||||
def run_command(command, shell=False):
|
||||
"""Run a shell command and return the result"""
|
||||
try:
|
||||
if not shell and not shutil.which(command[0]):
|
||||
return False, f"Command '{command[0]}' not found"
|
||||
|
||||
result = subprocess.run(command, shell=shell, check=True, text=True,
|
||||
stdout=subprocess.PIPE, stderr=subprocess.PIPE)
|
||||
return True, result.stdout.strip()
|
||||
except subprocess.CalledProcessError as e:
|
||||
return False, e.stderr.strip()
|
||||
except FileNotFoundError:
|
||||
return False, f"Command '{command[0]}' not found"
|
||||
return False, e.stderr.strip()
|
||||
|
||||
def ensure_dependencies():
|
||||
"""Check and install required dependencies for the dotfiles system"""
|
||||
|
Reference in New Issue
Block a user