From: Kefu Chai Date: Thu, 5 Feb 2015 08:33:08 +0000 (+0800) Subject: ceph_objectstore_tool: fix check_output on python2.6 X-Git-Tag: v0.93~83^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=15350a088d84bc6fc664f0d3f5d09b35f58b2144;p=ceph.git ceph_objectstore_tool: fix check_output on python2.6 * backported the subprocess.check_output from python2.7 Fixes: #10756 Signed-off-by: Kefu Chai --- diff --git a/src/test/ceph_objectstore_tool.py b/src/test/ceph_objectstore_tool.py index 600a386aa192..52ae51ce0257 100755 --- a/src/test/ceph_objectstore_tool.py +++ b/src/test/ceph_objectstore_tool.py @@ -1,7 +1,25 @@ #!/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