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

Method _run_docker_command

ci/docker_utils/DockerManager.py:36–219  ·  view source on GitHub ↗
(
        self,
        command: list[str],
        check: bool = True,
        stream_output: bool = False,
        timeout: Optional[int] = None,
        interrupt_pattern: Optional[str] = None,
        output_file: Optional[str] = None,
        container_name: Optional[str] = None,
    )

Source from the content-addressed store, hash-verified

34 pass
35
36 def _run_docker_command(
37 self,
38 command: list[str],
39 check: bool = True,
40 stream_output: bool = False,
41 timeout: Optional[int] = None,
42 interrupt_pattern: Optional[str] = None,
43 output_file: Optional[str] = None,
44 container_name: Optional[str] = None,
45 ) -> subprocess.CompletedProcess[str]:
46 docker_cmd = get_docker_command()
47 full_command = [docker_cmd] + command
48 print(f"Executing Docker command: {' '.join(full_command)}")
49
50 # Set environment to prevent MSYS2/Git Bash path conversion on Windows
51 env = os.environ.copy()
52 # Set UTF-8 encoding environment variables for Windows
53 env["PYTHONIOENCODING"] = "utf-8"
54 env["PYTHONUTF8"] = "1"
55 # Only set MSYS_NO_PATHCONV if we're in a Git Bash/MSYS2 environment
56 if (
57 "MSYSTEM" in os.environ
58 or os.environ.get("TERM") == "xterm"
59 or "bash.exe" in os.environ.get("SHELL", "")
60 ):
61 env["MSYS_NO_PATHCONV"] = "1"
62
63 if stream_output:
64 # Use RunningProcess for streaming output
65 import re
66 import time
67
68 from running_process import EndOfStream
69
70 proc = RunningProcess(full_command, env=env, auto_run=True)
71 timeout_occurred = False
72 start_time = time.time()
73
74 # Open output file if specified
75 output_handle = None
76 if output_file:
77 try:
78 output_handle = open(output_file, "w", encoding="utf-8")
79 except KeyboardInterrupt as ki:
80 handle_keyboard_interrupt(ki)
81 raise
82 except Exception as e:
83 print(f"Warning: Could not open output file {output_file}: {e}")
84
85 try:
86 # Use a reasonable line timeout (1 second) so we can check the overall timeout frequently
87 line_timeout = 1.0
88 while True:
89 try:
90 # Check timeout before trying to read next line
91 if timeout and (time.time() - start_time) > timeout:
92 print(
93 f"Timeout reached ({timeout}s), terminating container..."

Callers 7

pull_imageMethod · 0.95
run_containerMethod · 0.95
get_container_logsMethod · 0.95
stop_containerMethod · 0.95
remove_containerMethod · 0.95

Calls 10

get_docker_commandFunction · 0.90
timeMethod · 0.80
printFunction · 0.50
copyMethod · 0.45
getMethod · 0.45
writeMethod · 0.45
flushMethod · 0.45
waitMethod · 0.45
closeMethod · 0.45

Tested by

no test coverage detected