MCPcopy Create free account
hub / github.com/FastLED/FastLED / _run_command

Function _run_command

ci/util/bin_2_elf.py:13–42  ·  view source on GitHub ↗

Run a command using subprocess and capture the output. Args: command (list or str): 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] | str, show_output: bool = False)

Source from the content-addressed store, hash-verified

11
12
13def _run_command(command: list[str] | str, show_output: bool = False) -> str:
14 """
15 Run a command using subprocess and capture the output.
16
17 Args:
18 command (list or str): Command to run.
19 show_output (bool): Print command and its output if True.
20
21 Returns:
22 str: Standard output of the command.
23
24 Raises:
25 RuntimeError: If the command fails.
26 """
27 if isinstance(command, str):
28 command = [command]
29
30 if show_output:
31 print(f"Running command: {' '.join(command)}")
32
33 result = subprocess.run(command, capture_output=True, text=True)
34 if result.returncode != 0:
35 if show_output:
36 print(f"Command failed: {' '.join(command)}")
37 print(f"Error: {result.stderr}")
38 raise RuntimeError(f"Command failed: {' '.join(command)}\n{result.stderr}")
39
40 if show_output and result.stdout:
41 print(f"Command output: {result.stdout}")
42 return result.stdout
43
44
45def _detect_platform_from_paths(as_path: Path, ld_path: Path):

Callers 3

_create_dummy_elfFunction · 0.85
_update_elf_sectionsFunction · 0.85

Calls 2

printFunction · 0.50
runMethod · 0.45

Tested by

no test coverage detected