MCPcopy Index your code
hub / github.com/ipython/ipython / get_output_error_code

Function get_output_error_code

IPython/utils/_process_common.py:164–186  ·  view source on GitHub ↗

Return (standard output, standard error, return code) of executing cmd in a shell. Accepts the same arguments as os.system(). Parameters ---------- cmd : str or list A command to be executed in the system shell. Returns ------- stdout : str stderr : str

(cmd: str | list[str])

Source from the content-addressed store, hash-verified

162
163
164def get_output_error_code(cmd: str | list[str]) -> tuple[str, str, int | None]:
165 """Return (standard output, standard error, return code) of executing cmd
166 in a shell.
167
168 Accepts the same arguments as os.system().
169
170 Parameters
171 ----------
172 cmd : str or list
173 A command to be executed in the system shell.
174
175 Returns
176 -------
177 stdout : str
178 stderr : str
179 returncode: int
180 """
181
182 result = process_handler(cmd, lambda p: (p.communicate(), p))
183 if result is None:
184 return '', '', None
185 (out, err), p = result
186 return py3compat.decode(out), py3compat.decode(err), p.returncode
187
188def arg_split(commandline: str, posix: bool = False, strict: bool = True) -> list[str]:
189 """Split a command line's arguments in a shell-like manner.

Callers 5

getoutputMethod · 0.90
help_output_testFunction · 0.90
help_all_output_testFunction · 0.90
getoutputerrorFunction · 0.85

Calls 1

process_handlerFunction · 0.85

Tested by 1

Used in the wild real call sites across dependent graphs

searching dependent graphs…