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

Function create_pio_process

ci/util/pio_runner.py:32–93  ·  view source on GitHub ↗

Create a RunningProcess for PlatformIO commands with Git Bash compatibility. On Windows Git Bash: Runs command via cmd.exe with clean environment On other platforms: Runs command directly Args: cmd: Command to execute as list of strings cwd: Working directory for comman

(
    cmd: list[str],
    cwd: Path | str,
    output_formatter: Any | None = None,
    auto_run: bool = True,
)

Source from the content-addressed store, hash-verified

30
31
32def create_pio_process(
33 cmd: list[str],
34 cwd: Path | str,
35 output_formatter: Any | None = None,
36 auto_run: bool = True,
37) -> RunningProcess:
38 """Create a RunningProcess for PlatformIO commands with Git Bash compatibility.
39
40 On Windows Git Bash: Runs command via cmd.exe with clean environment
41 On other platforms: Runs command directly
42
43 Args:
44 cmd: Command to execute as list of strings
45 cwd: Working directory for command execution
46 output_formatter: Optional formatter for output lines
47 auto_run: If True, start the process immediately
48
49 Returns:
50 RunningProcess instance configured for the current environment
51 """
52 env = get_pio_execution_env()
53
54 # Convert cwd to Path if it's a string (RunningProcess expects Path | None)
55 cwd_path = Path(cwd) if isinstance(cwd, str) else cwd
56
57 if should_use_cmd_runner():
58 # Windows Git Bash: Convert to shell command for cmd.exe
59 cmd_str = format_cmd_for_shell(cmd)
60 proc = RunningProcess(
61 cmd_str,
62 cwd=cwd_path,
63 auto_run=auto_run,
64 output_formatter=output_formatter,
65 env=env,
66 shell=True, # Use shell=True for cmd.exe execution
67 )
68 else:
69 # Linux/Mac or native Windows shell: Direct execution
70 proc = RunningProcess(
71 cmd,
72 cwd=cwd_path,
73 auto_run=auto_run,
74 output_formatter=output_formatter,
75 env=env,
76 )
77
78 # Register process for orphan cleanup by daemon and for atexit killing
79 if auto_run and proc.proc is not None and isinstance(proc.proc, subprocess.Popen):
80 popen: subprocess.Popen[Any] = proc.proc
81 pid = popen.pid
82 register_build_process(
83 root_pid=pid,
84 project_dir=str(cwd),
85 )
86 # Unregister on normal exit
87 atexit.register(unregister_build_process)
88
89 # Also register with process killer for atexit cleanup

Callers 2

run_compileFunction · 0.90
run_uploadFunction · 0.90

Calls 7

get_pio_execution_envFunction · 0.90
should_use_cmd_runnerFunction · 0.90
format_cmd_for_shellFunction · 0.90
register_build_processFunction · 0.90
register_pio_processFunction · 0.90
unregister_pio_processFunction · 0.90
registerMethod · 0.45

Tested by

no test coverage detected