]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
ceph_objectstore_tool: fix check_output on python2.6
authorKefu Chai <kchai@redhat.com>
Thu, 5 Feb 2015 08:33:08 +0000 (16:33 +0800)
committerDavid Zafman <dzafman@redhat.com>
Tue, 3 Mar 2015 19:21:00 +0000 (11:21 -0800)
* backported the subprocess.check_output from python2.7

Fixes: #10756
Signed-off-by: Kefu Chai <kchai@redhat.com>
(cherry picked from commit 15350a088d84bc6fc664f0d3f5d09b35f58b2144)

Conflicts:
src/test/ceph_objectstore_tool.py

src/test/ceph_objectstore_tool.py

index b76f873ae8e7243b6ab750a3dde0a4173899d8d8..ab281dca4902baf7007ef9115807e86d822a53c8 100755 (executable)
@@ -1,7 +1,26 @@
 #!/usr/bin/env python
 
 from subprocess import call
-from subprocess import check_output
+try:
+    from subprocess import check_output
+except ImportError:
+    def check_output(*popenargs, **kwargs):
+        import subprocess
+        # backported from python 2.7 stdlib
+        process = subprocess.Popen(
+           stdout=subprocess.PIPE, *popenargs, **kwargs)
+        output, unused_err = process.communicate()
+        retcode = process.poll()
+        if retcode:
+            cmd = kwargs.get("args")
+            if cmd is None:
+                cmd = popenargs[0]
+            error = subprocess.CalledProcessError(retcode, cmd)
+            error.output = output
+            raise error
+        return output
+
+import subprocess
 import os
 import time
 import sys