From: Kefu Chai Date: Sun, 19 Jul 2020 09:35:16 +0000 (+0800) Subject: qa/tasks: drop python2 support X-Git-Tag: v16.1.0~1654^2~12 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=4aa537b7391ca085898400bf8182c3feaf3c81bf;p=ceph.git qa/tasks: drop python2 support Signed-off-by: Kefu Chai --- diff --git a/qa/tasks/autotest.py b/qa/tasks/autotest.py index a78987dca70e..297c1a4cbb71 100644 --- a/qa/tasks/autotest.py +++ b/qa/tasks/autotest.py @@ -5,8 +5,6 @@ import json import logging import os -import six - from teuthology import misc as teuthology from teuthology.parallel import parallel from teuthology.orchestra import run @@ -50,7 +48,7 @@ def task(ctx, config): log.info('Making a separate scratch dir for every client...') for role in config.keys(): - assert isinstance(role, six.string_types) + assert isinstance(role, str) PREFIX = 'client.' assert role.startswith(PREFIX) id_ = role[len(PREFIX):] @@ -105,7 +103,7 @@ def _run_tests(testdir, remote, role, tests): """ Spawned to run test on remote site """ - assert isinstance(role, six.string_types) + assert isinstance(role, str) PREFIX = 'client.' assert role.startswith(PREFIX) id_ = role[len(PREFIX):] diff --git a/qa/tasks/cram.py b/qa/tasks/cram.py index d06f09440a6a..8a2189d40994 100644 --- a/qa/tasks/cram.py +++ b/qa/tasks/cram.py @@ -4,8 +4,6 @@ Cram tests import logging import os -import six - from tasks.util.workunit import get_refspec_after_overrides from teuthology import misc as teuthology @@ -126,7 +124,7 @@ def _run_tests(ctx, role): :param ctx: Context :param role: Roles """ - assert isinstance(role, six.string_types) + assert isinstance(role, str) PREFIX = 'client.' assert role.startswith(PREFIX) id_ = role[len(PREFIX):] diff --git a/qa/tasks/devstack.py b/qa/tasks/devstack.py index 9243071a4bf0..e3bba302b0d5 100644 --- a/qa/tasks/devstack.py +++ b/qa/tasks/devstack.py @@ -1,12 +1,10 @@ #!/usr/bin/env python import contextlib import logging -from io import BytesIO import textwrap -from configparser import ConfigParser - -import six import time +from configparser import ConfigParser +from io import BytesIO, StringIO from teuthology.orchestra import run from teuthology import misc @@ -206,7 +204,7 @@ def update_devstack_config_files(devstack_node, secret_uuid): parser.read_file(config_stream) for (key, value) in update_dict.items(): parser.set(section, key, value) - out_stream = six.StringIO() + out_stream = StringIO() parser.write(out_stream) out_stream.seek(0) return out_stream @@ -251,7 +249,7 @@ def update_devstack_config_files(devstack_node, secret_uuid): file_name = update['name'] options = update['options'] config_data = misc.get_file(devstack_node, file_name, sudo=True) - config_stream = six.StringIO(config_data) + config_stream = StringIO(config_data) backup_config(devstack_node, file_name) new_config_stream = update_config(file_name, config_stream, options) misc.sudo_write_file(devstack_node, file_name, new_config_stream) diff --git a/qa/tasks/omapbench.py b/qa/tasks/omapbench.py index af0793d95644..a5bd3a4df23f 100644 --- a/qa/tasks/omapbench.py +++ b/qa/tasks/omapbench.py @@ -4,8 +4,6 @@ Run omapbench executable within teuthology import contextlib import logging -import six - from teuthology.orchestra import run from teuthology import misc as teuthology @@ -50,7 +48,7 @@ def task(ctx, config): testdir = teuthology.get_testdir(ctx) print(str(config.get('increment',-1))) for role in config.get('clients', ['client.0']): - assert isinstance(role, six.string_types) + assert isinstance(role, str) PREFIX = 'client.' assert role.startswith(PREFIX) id_ = role[len(PREFIX):] diff --git a/qa/tasks/rados.py b/qa/tasks/rados.py index edce8dc805bf..349f46efcc95 100644 --- a/qa/tasks/rados.py +++ b/qa/tasks/rados.py @@ -6,7 +6,6 @@ import logging import gevent from teuthology import misc as teuthology -import six from teuthology.orchestra import run @@ -231,7 +230,7 @@ def task(ctx, config): existing_pools = config.get('pools', []) created_pools = [] for role in config.get('clients', clients): - assert isinstance(role, six.string_types) + assert isinstance(role, str) PREFIX = 'client.' assert role.startswith(PREFIX) id_ = role[len(PREFIX):] diff --git a/qa/tasks/radosbench.py b/qa/tasks/radosbench.py index a2c4f069353e..0804840c5921 100644 --- a/qa/tasks/radosbench.py +++ b/qa/tasks/radosbench.py @@ -7,7 +7,6 @@ import logging from teuthology.orchestra import run from teuthology import misc as teuthology -import six log = logging.getLogger(__name__) @@ -55,7 +54,7 @@ def task(ctx, config): create_pool = config.get('create_pool', True) for role in config.get('clients', ['client.0']): - assert isinstance(role, six.string_types) + assert isinstance(role, str) PREFIX = 'client.' assert role.startswith(PREFIX) id_ = role[len(PREFIX):] diff --git a/qa/tasks/radosbenchsweep.py b/qa/tasks/radosbenchsweep.py index 0aeb7218681c..df0ba1ed1c5a 100644 --- a/qa/tasks/radosbenchsweep.py +++ b/qa/tasks/radosbenchsweep.py @@ -11,7 +11,6 @@ from itertools import product from teuthology.orchestra import run from teuthology import misc as teuthology -import six log = logging.getLogger(__name__) @@ -169,7 +168,7 @@ def run_radosbench(ctx, config, f, num_osds, size, replica, rep): log.info(' repetition =' + str(rep)) for role in config.get('clients', ['client.0']): - assert isinstance(role, six.string_types) + assert isinstance(role, str) PREFIX = 'client.' assert role.startswith(PREFIX) id_ = role[len(PREFIX):] diff --git a/qa/tasks/watch_notify_same_primary.py b/qa/tasks/watch_notify_same_primary.py index 7c034961c382..448fee193ca1 100644 --- a/qa/tasks/watch_notify_same_primary.py +++ b/qa/tasks/watch_notify_same_primary.py @@ -2,11 +2,10 @@ """ watch_notify_same_primary task """ -from six import StringIO +from io import StringIO import contextlib import logging -import six from teuthology.orchestra import run from teuthology.contextutil import safe_while @@ -43,7 +42,7 @@ def task(ctx, config): clients = config.get('clients', ['client.0']) assert len(clients) == 1 role = clients[0] - assert isinstance(role, six.string_types) + assert isinstance(role, str) PREFIX = 'client.' assert role.startswith(PREFIX) (remote,) = ctx.cluster.only(role).remotes.keys() diff --git a/qa/tasks/watch_notify_stress.py b/qa/tasks/watch_notify_stress.py index e5e380492e0e..47747b1ca018 100644 --- a/qa/tasks/watch_notify_stress.py +++ b/qa/tasks/watch_notify_stress.py @@ -4,7 +4,6 @@ test_stress_watch task import contextlib import logging -import six from teuthology.orchestra import run from teuthology.task import proc_thrasher @@ -37,7 +36,7 @@ def task(ctx, config): remotes = [] for role in config.get('clients', ['client.0']): - assert isinstance(role, six.string_types) + assert isinstance(role, str) PREFIX = 'client.' assert role.startswith(PREFIX) id_ = role[len(PREFIX):] diff --git a/qa/workunits/mon/caps.py b/qa/workunits/mon/caps.py index 0268851b3b95..26c0cd14ccb8 100644 --- a/qa/workunits/mon/caps.py +++ b/qa/workunits/mon/caps.py @@ -10,8 +10,6 @@ import os import io import re -import six - from ceph_argparse import * # noqa keyring_base = '/tmp/cephtest-caps.keyring' @@ -21,8 +19,7 @@ class UnexpectedReturn(Exception): if isinstance(cmd, list): self.cmd = ' '.join(cmd) else: - assert isinstance(cmd, str) or isinstance(cmd, six.text_type), \ - 'cmd needs to be either a list or a str' + assert isinstance(cmd, str), 'cmd needs to be either a list or a str' self.cmd = cmd self.cmd = str(self.cmd) self.ret = int(ret) @@ -36,7 +33,7 @@ class UnexpectedReturn(Exception): def call(cmd): if isinstance(cmd, list): args = cmd - elif isinstance(cmd, str) or isinstance(cmd, six.text_type): + elif isinstance(cmd, str): args = shlex.split(cmd) else: assert False, 'cmd is not a string/unicode nor a list!' @@ -64,15 +61,15 @@ def expect(cmd, expected_ret): return p -def expect_to_file(cmd, expected_ret, out_file, mode='a'): +def expect_to_file(cmd, expected_ret, out_file): # Let the exception be propagated to the caller p = expect(cmd, expected_ret) assert p.returncode == expected_ret, \ 'expected result doesn\'t match and no exception was thrown!' - with io.open(out_file, mode) as file: - file.write(six.text_type(p.stdout.read())) + with io.open(out_file, 'ab') as file: + file.write(p.stdout.read()) return p @@ -86,7 +83,7 @@ class Command: self.args = [] for s in j['sig']: if not isinstance(s, dict): - assert isinstance(s, str) or isinstance(s,six.text_type), \ + assert isinstance(s, str), \ 'malformatted signature cid {0}: {1}\n{2}'.format(cid,s,j) if len(self.sig) > 0: self.sig += ' ' diff --git a/qa/workunits/mon/ping.py b/qa/workunits/mon/ping.py index edbd586026b6..1f6d0a1ddcb2 100755 --- a/qa/workunits/mon/ping.py +++ b/qa/workunits/mon/ping.py @@ -4,15 +4,13 @@ import json import shlex import subprocess -import six - class UnexpectedReturn(Exception): def __init__(self, cmd, ret, expected, msg): if isinstance(cmd, list): self.cmd = ' '.join(cmd) else: - assert isinstance(cmd, six.string_types) or isinstance(cmd, six.text_type), \ + assert isinstance(cmd, str), \ 'cmd needs to be either a list or a str' self.cmd = cmd self.cmd = str(self.cmd) @@ -28,7 +26,7 @@ class UnexpectedReturn(Exception): def call(cmd): if isinstance(cmd, list): args = cmd - elif isinstance(cmd, six.string_types) or isinstance(cmd, six.text_type): + elif isinstance(cmd, str): args = shlex.split(cmd) else: assert False, 'cmd is not a string/unicode nor a list!' diff --git a/src/powerdns/pdns-backend-rgw.py b/src/powerdns/pdns-backend-rgw.py index b943ed9b421b..5d773d2aabdd 100755 --- a/src/powerdns/pdns-backend-rgw.py +++ b/src/powerdns/pdns-backend-rgw.py @@ -53,7 +53,7 @@ from ConfigParser import SafeConfigParser, NoSectionError from flask import abort, Flask, request, Response from hashlib import sha1 as sha from time import gmtime, strftime -from six.moves.urllib.parse import urlparse +from urllib.parse import urlparse import argparse import base64 import hmac