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

Function run_pio_command

ci/util/pio_runner.py:96–163  ·  view source on GitHub ↗

Run a PlatformIO command with Git Bash compatibility. This is a simpler alternative to create_pio_process() for commands that don't need streaming output. The process is automatically tracked and will be killed on program exit if still running. Args: cmd: Command to execute

(
    cmd: list[str],
    cwd: Path | str | None = None,
    capture_output: bool = False,
    timeout: int | None = None,
)

Source from the content-addressed store, hash-verified

94
95
96def run_pio_command(
97 cmd: list[str],
98 cwd: Path | str | None = None,
99 capture_output: bool = False,
100 timeout: int | None = None,
101) -> subprocess.CompletedProcess[str]:
102 """Run a PlatformIO command with Git Bash compatibility.
103
104 This is a simpler alternative to create_pio_process() for commands that
105 don't need streaming output. The process is automatically tracked and will
106 be killed on program exit if still running.
107
108 Args:
109 cmd: Command to execute as list of strings
110 cwd: Working directory for command execution
111 capture_output: If True, capture stdout and stderr
112 timeout: Optional timeout in seconds
113
114 Returns:
115 subprocess.CompletedProcess result
116 """
117 env = get_pio_execution_env()
118 stdout_pipe = subprocess.PIPE if capture_output else None
119 stderr_pipe = subprocess.PIPE if capture_output else None
120 cwd_str = str(cwd) if cwd else None
121
122 if should_use_cmd_runner():
123 # Windows Git Bash: Run via cmd.exe with tracking
124 cmd_str = format_cmd_for_shell(cmd)
125 with TrackedPopen(
126 cmd_str,
127 shell=True,
128 env=env,
129 cwd=cwd_str,
130 stdout=stdout_pipe,
131 stderr=stderr_pipe,
132 text=True,
133 ) as tracked:
134 try:
135 stdout, stderr = tracked.communicate(timeout=timeout)
136 except subprocess.TimeoutExpired:
137 tracked.kill()
138 stdout, stderr = tracked.communicate()
139 raise subprocess.TimeoutExpired(
140 cmd, timeout or 0, output=stdout, stderr=stderr
141 )
142 retcode = tracked.returncode
143 return subprocess.CompletedProcess(cmd, retcode or 0, stdout, stderr)
144 else:
145 # Linux/Mac or native Windows shell: Direct execution with tracking
146 with TrackedPopen(
147 cmd,
148 env=env,
149 cwd=cwd_str,
150 stdout=stdout_pipe,
151 stderr=stderr_pipe,
152 text=True,
153 ) as tracked:

Callers 1

_run_pio_sizeFunction · 0.90

Calls 6

get_pio_execution_envFunction · 0.90
should_use_cmd_runnerFunction · 0.90
format_cmd_for_shellFunction · 0.90
TrackedPopenClass · 0.90
communicateMethod · 0.80
killMethod · 0.80

Tested by

no test coverage detected