]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
qa: always use subprocess.{DEVNULL,check_output}
authorKefu Chai <kchai@redhat.com>
Thu, 3 Sep 2020 04:46:48 +0000 (12:46 +0800)
committerKefu Chai <kchai@redhat.com>
Thu, 3 Sep 2020 05:09:16 +0000 (13:09 +0800)
no need to check for their existence, and prepare a replacement.
because we've migrated to python3. and we only support python3.6 and up.

Signed-off-by: Kefu Chai <kchai@redhat.com>
qa/standalone/special/ceph_objectstore_tool.py
qa/tasks/ceph_manager.py

index 17c3383233ceff21cd2817ab530893220c324b1d..d7d1694b35840dd6067132c6e644c28575c3d004 100755 (executable)
@@ -1,25 +1,6 @@
 #!/usr/bin/python3
 
-from __future__ import print_function
-from subprocess import call
-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
+from subprocess import call, check_output, DEVNULL
 
 import filecmp
 import os
@@ -33,11 +14,6 @@ import json
 import tempfile
 import platform
 
-try:
-    from subprocess import DEVNULL
-except ImportError:
-    DEVNULL = open(os.devnull, "wb")
-
 logging.basicConfig(format='%(levelname)s:%(message)s', level=logging.WARNING,
                     datefmt="%FT%T")
 
index 4c9c54ed9ff827dfb12d8c29b884318affc0d4c3..eaf7920ad5b5743eaa94db4fccde64126a497b6c 100644 (file)
@@ -15,6 +15,7 @@ import traceback
 import os
 
 from io import BytesIO, StringIO
+from subprocess import DEVNULL
 from teuthology import misc as teuthology
 from tasks.scrub import Scrubber
 from tasks.util.rados import cmd_erasure_code_profile
@@ -25,10 +26,6 @@ from teuthology.orchestra import run
 from teuthology.exceptions import CommandFailedError
 from tasks.thrasher import Thrasher
 
-try:
-    from subprocess import DEVNULL # py3k
-except ImportError:
-    DEVNULL = open(os.devnull, 'r+')  # type: ignore
 
 DEFAULT_CONF_PATH = '/etc/ceph/ceph.conf'