Permalink
Browse files

Merge branch 'return_external_2.6_compat' of https://github.com/lethl…

…iel/osc

Workaround for python26 due to missing subprocess.check_output.

Fixes: #355 ("subprocess.check_output() not in Python 2.6")
  • Loading branch information...
2 parents 5791d1b + 7581856 commit 03c25eb8f9ce8bc2bc6610061bee318ac731af91 @marcus-h marcus-h committed Nov 21, 2017
Showing with 10 additions and 0 deletions.
  1. +10 −0 osc/core.py
View
@@ -7572,6 +7572,16 @@ def return_external(filename, *args, **kwargs):
cmd = filename
try:
+ # backward compatibility for python 2.6
+ if 'check_output' not in dir(subprocess):
+ process = subprocess.Popen(cmd, stdout=subprocess.PIPE)
+ output, errstr = process.communicate()
+ retcode = process.poll()
+ if retcode:
+ error = subprocess.CalledProcessError(retcode, cmd)
+ error.output = output
+ raise error
+ return output
return subprocess.check_output(cmd, **kwargs)
except OSError as e:
if e.errno != errno.ENOENT:

0 comments on commit 03c25eb

Please sign in to comment.