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 whatev
(cmd)
| 112 | |
| 113 | |
| 114 | def getoutput(cmd): |
| 115 | """Run a command and return its stdout/stderr as a string. |
| 116 | |
| 117 | Parameters |
| 118 | ---------- |
| 119 | cmd : str or list |
| 120 | A command to be executed in the system shell. |
| 121 | |
| 122 | Returns |
| 123 | ------- |
| 124 | output : str |
| 125 | A string containing the combination of stdout and stderr from the |
| 126 | subprocess, in whatever order the subprocess originally wrote to its |
| 127 | file descriptors (so the order of the information in this string is the |
| 128 | correct order as would be seen if running the command in a terminal). |
| 129 | """ |
| 130 | out = process_handler(cmd, lambda p: p.communicate()[0], subprocess.STDOUT) |
| 131 | if out is None: |
| 132 | return '' |
| 133 | return py3compat.decode(out) |
| 134 | |
| 135 | |
| 136 | def getoutputerror(cmd): |
nothing calls this directly
no test coverage detected