added check_output to p2pool.__init__ to handle it not being present on python 2.6
authorForrest Voight <forrest@forre.st>
Fri, 30 Mar 2012 21:52:19 +0000 (17:52 -0400)
committerForrest Voight <forrest@forre.st>
Fri, 30 Mar 2012 21:54:21 +0000 (17:54 -0400)
p2pool/__init__.py

index b7350e1..e8d488f 100644 (file)
@@ -3,14 +3,22 @@ import sys
 import traceback
 import subprocess
 
+def check_output(*popenargs, **kwargs):
+    process = subprocess.Popen(stdout=subprocess.PIPE, *popenargs, **kwargs)
+    output, unused_err = process.communicate()
+    retcode = process.poll()
+    if retcode:
+        raise ValueError((retcode, output))
+    return output
+
 def _get_version():
     try:
         try:
-            return subprocess.check_output(['git', 'describe', '--always', '--dirty'], cwd=os.path.dirname(os.path.abspath(sys.argv[0]))).strip()
+            return check_output(['git', 'describe', '--always', '--dirty'], cwd=os.path.dirname(os.path.abspath(sys.argv[0]))).strip()
         except:
             pass
         try:
-            return subprocess.check_output(['git.cmd', 'describe', '--always', '--dirty'], cwd=os.path.dirname(os.path.abspath(sys.argv[0]))).strip()
+            return check_output(['git.cmd', 'describe', '--always', '--dirty'], cwd=os.path.dirname(os.path.abspath(sys.argv[0]))).strip()
         except:
             pass
         root_dir = os.path.abspath(os.path.dirname(sys.argv[0]))