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])
| 162 | |
| 163 | |
| 164 | def 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 | |
| 188 | def arg_split(commandline: str, posix: bool = False, strict: bool = True) -> list[str]: |
| 189 | """Split a command line's arguments in a shell-like manner. |
searching dependent graphs…