MCPcopy
hub / github.com/openai/plugins / run_cmd

Function run_cmd

plugins/ngs-analysis/scripts/ngs_run_utils.py:134–168  ·  view source on GitHub ↗
(cmd: list[str], cwd: Path, timeout: int | None = None)

Source from the content-addressed store, hash-verified

132
133
134def run_cmd(cmd: list[str], cwd: Path, timeout: int | None = None) -> dict[str, Any]:
135 started = now_iso()
136 try:
137 result = subprocess.run(
138 cmd,
139 cwd=cwd,
140 check=False,
141 stdout=subprocess.PIPE,
142 stderr=subprocess.STDOUT,
143 text=True,
144 timeout=timeout,
145 env=_effective_env(),
146 )
147 output = result.stdout or ""
148 return {
149 "cmd": cmd,
150 "cwd": str(cwd),
151 "started_at": started,
152 "finished_at": now_iso(),
153 "returncode": result.returncode,
154 "ok": result.returncode == 0,
155 "stdout_tail": output[-12000:],
156 }
157 except subprocess.TimeoutExpired as exc:
158 output = exc.stdout if isinstance(exc.stdout, str) else ""
159 return {
160 "cmd": cmd,
161 "cwd": str(cwd),
162 "started_at": started,
163 "finished_at": now_iso(),
164 "returncode": None,
165 "ok": False,
166 "error": f"TimeoutExpired: exceeded {timeout}s",
167 "stdout_tail": output[-12000:],
168 }
169
170
171def run_cmd_stdout_to_file(

Callers 15

execute_commandFunction · 0.90
execute_planFunction · 0.90
executeFunction · 0.90
execute_planFunction · 0.90
r_package_availableFunction · 0.90
mainFunction · 0.90
execute_planFunction · 0.90
execute_planFunction · 0.90
mainFunction · 0.90
execute_planFunction · 0.90
execute_packageFunction · 0.90
execute_planFunction · 0.90

Calls 3

_effective_envFunction · 0.85
runMethod · 0.80
now_isoFunction · 0.70

Tested by

no test coverage detected