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

This commit is contained in:
2025-03-10 20:23:15 +01:00
parent 6f2ec615ce
commit ee064f521b
2 changed files with 16 additions and 1 deletions

View File

@ -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"""