blob: afd705a187d76220bfaf3d55a21bd01494d44824 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
|
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 subprocess.CalledProcessError as e:
logger.error(f"command failed: {cmd}, {e.stderr}")
return None
|