Skip to content


Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP


Add Python 2.6 support #8

merged 1 commit into from

2 participants

Adam Baxter uams
Adam Baxter

No description provided.


Cool. Just want to double check that this works even when I use the Shell=True flag? I'm cool with it as long as you've tested it.


Lol. Read the comment on gist where it says that this is the same code as in python2.7 given that it was written in python. Thanks!

uams uams merged commit 5971f8c into from
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Oct 2, 2012
  1. Adam Baxter
This page is out of date. Refresh to see the latest.
Showing with 28 additions and 1 deletion.
  1. +22 −0
  2. +6 −1 geturl
@@ -0,0 +1,22 @@
+import subprocess
+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'])
+ 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
7 geturl
@@ -1,6 +1,11 @@
-from subprocess import check_output, CalledProcessError
+from subprocess import CalledProcessError
+ from subprocess import check_output
+except ImportError:
+ from check_output import check_output
import json
import sys
import os
Something went wrong with that request. Please try again.