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)
| 151 | return get_output_error_code(cmd)[:2] |
| 152 | |
| 153 | def get_output_error_code(cmd): |
| 154 | """Return (standard output, standard error, return code) of executing cmd |
| 155 | in a shell. |
| 156 | |
| 157 | Accepts the same arguments as os.system(). |
| 158 | |
| 159 | Parameters |
| 160 | ---------- |
| 161 | cmd : str or list |
| 162 | A command to be executed in the system shell. |
| 163 | |
| 164 | Returns |
| 165 | ------- |
| 166 | stdout : str |
| 167 | stderr : str |
| 168 | returncode: int |
| 169 | """ |
| 170 | |
| 171 | out_err, p = process_handler(cmd, lambda p: (p.communicate(), p)) |
| 172 | if out_err is None: |
| 173 | return '', '', p.returncode |
| 174 | out, err = out_err |
| 175 | return py3compat.decode(out), py3compat.decode(err), p.returncode |
| 176 | |
| 177 | def arg_split(s, posix=False, strict=True): |
| 178 | """Split a command line's arguments in a shell-like manner. |