diff options
author | Walter 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) |
commit | d294502f536ffb957327c8f3df9745ce8d151bff (patch) | |
tree | 9e25ec415875d98d7c38fc5acb0d6dd7063c142a | |
parent | d0b549ee9f0731418acbc8fd292fd1cb38ef984f (diff) |
add back in missing check_output
-rw-r--r-- | utils.py | 21 |
1 files changed, 21 insertions, 0 deletions
@@ -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 |