diff options
author | Jed Brown <jed@59A2.org> | 2013-08-20 08:36:34 -0500 |
---|---|---|
committer | Jed Brown <jed@59A2.org> | 2013-08-20 08:36:34 -0500 |
commit | 5bf4193c0683f179c6a537781aeb8501f5ba38c5 (patch) | |
tree | 1259b126dcc1487d1d071bfc4e4422a85cba82a4 /git-fat | |
parent | 4664f2dc2eee13b86d2e426780fd1130e0086e9f (diff) | |
parent | e013c50fcb78c1c6442f4a6496eff26af82289ff (diff) | |
download | git-fat-5bf4193c0683f179c6a537781aeb8501f5ba38c5.tar.gz |
Merge branch 'python2.6-compatibility' of github:chhitz/git-fat (PR #14)
* 'python2.6-compatibility' of github:chhitz/git-fat:
make compatible with python2.6
Diffstat (limited to 'git-fat')
-rwxr-xr-x | git-fat | 25 |
1 files changed, 25 insertions, 0 deletions
@@ -14,6 +14,31 @@ import threading import time import collections +try: + from subprocess import check_output + del check_output +except ImportError: + def backport_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']) + Python 2.6.2 + """ + process = subprocess.Popen(stdout=subprocess.PIPE, *popenargs, **kwargs) + output, unused_err = process.communicate() + retcode = process.poll() + if retcode: + cmd = kwargs.get("args") + if cmd is None: + cmd = popenargs[0] + error = subprocess.CalledProcessError(retcode, cmd) + error.output = output + raise error + return output + subprocess.check_output = backport_check_output + BLOCK_SIZE = 4096 def verbose_stderr(*args, **kwargs): |