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
diff --git a/qpid/cpp/src/tests/plano.py b/qpid/cpp/src/tests/plano.py
index e27da06..e76fba0 100644
--- a/qpid/cpp/src/tests/plano.py
+++ b/qpid/cpp/src/tests/plano.py
@@ -414,12 +414,12 @@
     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 @@
             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