| Conditions | 3 |
| Total Lines | 19 |
| Code Lines | 12 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
| 1 | import subprocess |
||
| 4 | def subprocess_check_output(*popenargs, **kwargs): |
||
| 5 | # Backport of subprocess.check_output taken from |
||
| 6 | # https://gist.github.com/edufelipe/1027906 |
||
| 7 | # |
||
| 8 | # Originally from Python 2.7 stdlib under PSF, compatible with BSD-3 |
||
| 9 | # Copyright (c) 2003-2005 by Peter Astrand <[email protected]> |
||
| 10 | # Changes by Eduardo Felipe |
||
| 11 | |||
| 12 | process = subprocess.Popen(stdout=subprocess.PIPE, *popenargs, **kwargs) |
||
| 13 | output, unused_err = process.communicate() |
||
| 14 | retcode = process.poll() |
||
| 15 | if retcode: |
||
| 16 | cmd = kwargs.get("args") |
||
| 17 | if cmd is None: |
||
| 18 | cmd = popenargs[0] |
||
| 19 | error = subprocess.CalledProcessError(retcode, cmd) |
||
| 20 | error.output = output |
||
| 21 | raise error |
||
| 22 | return output |
||
| 23 | |||
| 27 |
The coding style of this project requires that you add a docstring to this code element. Below, you find an example for methods:
If you would like to know more about docstrings, we recommend to read PEP-257: Docstring Conventions.