Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorWalter Bender <walter.bender@gmail.com>2013-03-12 17:33:53 (GMT)
committer Walter Bender <walter.bender@gmail.com>2013-03-12 17:33:53 (GMT)
commitd294502f536ffb957327c8f3df9745ce8d151bff (patch)
tree9e25ec415875d98d7c38fc5acb0d6dd7063c142a
parentd0b549ee9f0731418acbc8fd292fd1cb38ef984f (diff)
add back in missing check_output
-rw-r--r--utils.py21
1 files changed, 21 insertions, 0 deletions
diff --git a/utils.py b/utils.py
index f196359..ecbbf7a 100644
--- a/utils.py
+++ b/utils.py
@@ -299,3 +299,24 @@ class SVG:
def set_stroke_width(self, stroke_width=1.0):
self._stroke_width = stroke_width
+
+def check_output(command, warning):
+ ''' Workaround for old systems without subprocess.check_output'''
+ if hasattr(subprocess, 'check_output'):
+ try:
+ output = subprocess.check_output(command)
+ except subprocess.CalledProcessError:
+ print(warning)
+ return None
+ else:
+ import commands
+
+ cmd = ''
+ for c in command:
+ cmd += c
+ cmd += ' '
+ (status, output) = commands.getstatusoutput(cmd)
+ if status != 0:
+ print(warning)
+ return None
+ return output