Run a command using subprocess and capture the output. Args: command (list): Command to run. show_output (bool): Print command and its output if True. Returns: str: Standard output of the command. Raises: RuntimeError: If the command fails.
(command: list[str], show_output: bool = False)
| 8 | |
| 9 | |
| 10 | def run_command(command: list[str], show_output: bool = False) -> str: |
| 11 | """ |
| 12 | Run a command using subprocess and capture the output. |
| 13 | |
| 14 | Args: |
| 15 | command (list): Command to run. |
| 16 | show_output (bool): Print command and its output if True. |
| 17 | |
| 18 | Returns: |
| 19 | str: Standard output of the command. |
| 20 | |
| 21 | Raises: |
| 22 | RuntimeError: If the command fails. |
| 23 | """ |
| 24 | if show_output: |
| 25 | print(f"Running command: {' '.join(command)}") |
| 26 | result = RunningProcess.run(command, cwd=None, check=False, timeout=60) |
| 27 | if result.returncode != 0: |
| 28 | raise RuntimeError(f"Command failed: {' '.join(command)}\n{result.stdout}") |
| 29 | if show_output and result.stdout: |
| 30 | print(f"Command output: {result.stdout}") |
| 31 | return result.stdout |
| 32 | |
| 33 | |
| 34 | def analyze_elf_file(objdump_path: Path, cppfilt_path: Path, elf_file: Path): |
no test coverage detected