From 7581856d9b5f0aa26c497fa6948dd9530c4697ed Mon Sep 17 00:00:00 2001 From: lethliel Date: Tue, 21 Nov 2017 11:36:50 +0100 Subject: [PATCH] added compat code for python 2.6 if subprocess has no method check_output us Popen instead --- osc/core.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/osc/core.py b/osc/core.py index 10f28ce0..5ee02ee5 100644 --- a/osc/core.py +++ b/osc/core.py @@ -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: