From: Kefu Chai Date: Thu, 3 Sep 2020 04:46:48 +0000 (+0800) Subject: qa: always use subprocess.{DEVNULL,check_output} X-Git-Tag: v16.1.0~1151^2~1 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=eda90040adf80ceb4c2bc437af9615293c9b2781;p=ceph.git qa: always use subprocess.{DEVNULL,check_output} 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 --- diff --git a/qa/standalone/special/ceph_objectstore_tool.py b/qa/standalone/special/ceph_objectstore_tool.py index 17c3383233ce..d7d1694b3584 100755 --- a/qa/standalone/special/ceph_objectstore_tool.py +++ b/qa/standalone/special/ceph_objectstore_tool.py @@ -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") diff --git a/qa/tasks/ceph_manager.py b/qa/tasks/ceph_manager.py index 4c9c54ed9ff8..eaf7920ad5b5 100644 --- a/qa/tasks/ceph_manager.py +++ b/qa/tasks/ceph_manager.py @@ -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'