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

Function getoutput

IPython/utils/_process_common.py:124–143  ·  view source on GitHub ↗

Run a command and return its stdout/stderr as a string. Parameters ---------- cmd : str or list A command to be executed in the system shell. Returns ------- output : str A string containing the combination of stdout and stderr from the subprocess, in wh

(cmd: str | list[str])

Source from the content-addressed store, hash-verified

122
123
124def getoutput(cmd: str | list[str]) -> str:
125 """Run a command and return its stdout/stderr as a string.
126
127 Parameters
128 ----------
129 cmd : str or list
130 A command to be executed in the system shell.
131
132 Returns
133 -------
134 output : str
135 A string containing the combination of stdout and stderr from the
136 subprocess, in whatever order the subprocess originally wrote to its
137 file descriptors (so the order of the information in this string is the
138 correct order as would be seen if running the command in a terminal).
139 """
140 out = process_handler(cmd, lambda p: p.communicate()[0], subprocess.STDOUT)
141 if out is None:
142 return ''
143 return py3compat.decode(out)
144
145
146def getoutputerror(cmd: str | list[str]) -> tuple[str, str]:

Callers

nothing calls this directly

Calls 1

process_handlerFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…