From e013c50fcb78c1c6442f4a6496eff26af82289ff Mon Sep 17 00:00:00 2001 From: Christian Hitz Date: Tue, 20 Aug 2013 11:23:41 +0200 Subject: make compatible with python2.6 patch from https://gist.github.com/edufelipe/1027906 --- git-fat | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) (limited to 'git-fat') diff --git a/git-fat b/git-fat index f654fab..ce98fb8 100755 --- a/git-fat +++ b/git-fat @@ -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): -- cgit v1.2.1