summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJustin Ross <jross@apache.org>2016-05-11 18:45:26 +0000
committerJustin Ross <jross@apache.org>2016-05-11 18:45:26 +0000
commit5fdd81bf916d0499b84c0c75f853eb710e35157f (patch)
treeb6dc92b7b6a878df6457c2194bd1dea2d931aa31
parent58ac9b9bec850fe58c3f23c17e185cda9614c8be (diff)
downloadqpid-python-5fdd81bf916d0499b84c0c75f853eb710e35157f.tar.gz
QPID-7207: Make call_for_output Python 2.6 compatible
git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@1743410 13f79535-47bb-0310-9956-ffa450edef68
-rw-r--r--qpid/cpp/src/tests/plano.py22
1 files changed, 19 insertions, 3 deletions
diff --git a/qpid/cpp/src/tests/plano.py b/qpid/cpp/src/tests/plano.py
index e27da06e67..e76fba03eb 100644
--- a/qpid/cpp/src/tests/plano.py
+++ b/qpid/cpp/src/tests/plano.py
@@ -414,12 +414,12 @@ def _init_call(command, args, kwargs):
return command, kwargs
def call(command, *args, **kwargs):
- command, args = _init_call(command, args, kwargs)
+ command, kwargs = _init_call(command, args, kwargs)
_subprocess.check_call(command, **kwargs)
def call_for_output(command, *args, **kwargs):
- command, args = _init_call(command, args, kwargs)
- return _subprocess.check_output(command, **kwargs)
+ command, kwargs = _init_call(command, args, kwargs)
+ return _subprocess_check_output(command, **kwargs)
def make_archive(input_dir, output_dir, archive_stem):
temp_dir = make_temp_dir()
@@ -541,3 +541,19 @@ def _copytree(src, dst, symlinks=False, ignore=None):
errors.append((src, dst, str(why)))
if errors:
raise _shutil.Error(errors)
+
+# For Python 2.6 compatibility
+def _subprocess_check_output(command, **kwargs):
+ kwargs["stdout"] = _subprocess.PIPE
+
+ proc = _subprocess.Popen(command, **kwargs)
+ output = proc.communicate()[0]
+ exit_code = proc.poll()
+
+ if exit_code not in (None, 0):
+ error = _subprocess.CalledProcessError(exit_code, command)
+ error.output = output
+
+ raise error
+
+ return output