import subprocess import logging from typing import List, Optional def run_shell_command(cmd: List[str], logger: logging.Logger) -> Optional[str]: logger.debug(f"running command: {cmd}") try: return subprocess.run( cmd, capture_output=True, text=True, check=True ).stdout.strip() except FileNotFoundError as e: logger.error(f"excecutable not found: {cmd[0]}, {e}") return None except subprocess.CalledProcessError as e: logger.error(f"command failed: {cmd}, {e.stderr}") return None