1
0
mirror of https://github.com/openSUSE/osc.git synced 2024-09-20 01:06:17 +02:00

added compat code for python 2.6

if subprocess has no method check_output us Popen instead
This commit is contained in:
lethliel 2017-11-21 11:36:50 +01:00
parent 3c1bb1cf0a
commit 7581856d9b

View File

@ -7567,6 +7567,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: