You can clone with
def check_output(*popenargs, **kwargs):
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'])
process = subprocess.Popen(stdout=subprocess.PIPE, *popenargs, **kwargs)
output, unused_err = process.communicate()
retcode = process.poll()
cmd = kwargs.get("args")
if cmd is None:
cmd = popenargs
error = subprocess.CalledProcessError(retcode, cmd)
error.output = output
raise subprocess.CalledProcessError(retcode, cmd, output=output)
CalledProcessError doesn't take kwargs in earlier versions of Python...
@rcoup Thanks for the report. Updated the gist so the output is set the right way.
Good job, thanks!
thank you for this.