r"""Run command with arguments and return its output as a byte string. Backported from Python 2.7 as it's implemented as pure python on stdlib. >>> check_output(['/usr/bin/python', '--version']) Python 2.6.2
(*popenargs, **kwargs)
| 23 | except (NameError, ImportError): |
| 24 | import subprocess |
| 25 | def check_output(*popenargs, **kwargs): |
| 26 | r"""Run command with arguments and return its output as a byte string. |
| 27 | |
| 28 | Backported from Python 2.7 as it's implemented as pure python on stdlib. |
| 29 | |
| 30 | >>> check_output(['/usr/bin/python', '--version']) |
| 31 | Python 2.6.2 |
| 32 | """ |
| 33 | process = subprocess.Popen(stdout=subprocess.PIPE, *popenargs, **kwargs) |
| 34 | output, unused_err = process.communicate() |
| 35 | retcode = process.poll() |
| 36 | if retcode: |
| 37 | cmd = kwargs.get("args") |
| 38 | if cmd is None: |
| 39 | cmd = popenargs[0] |
| 40 | error = subprocess.CalledProcessError(retcode, cmd) |
| 41 | error.output = output |
| 42 | raise error |
| 43 | return output |
| 44 | subprocess.check_output = check_output |
| 45 | |
| 46 | import logging |