Removed Python 2 support and six

Remove the use of six and move forward with Python3 only.

Change-Id: Ia4694704e001df03ac489a4d8a491c1c784ec3f9
This commit is contained in:
Thomas Goirand 2024-03-11 12:49:13 +01:00
parent e8eb9511d2
commit 666fc883fa
7 changed files with 14 additions and 22 deletions

View File

@ -1,4 +1,4 @@
#!/usr/bin/env python
#!/usr/bin/env python3
# Copyright (c) 2010-2012 OpenStack Foundation
#
# Licensed under the Apache License, Version 2.0 (the "License");

View File

@ -1,4 +1,4 @@
#!/usr/bin/env python
#!/usr/bin/env python3
# Copyright (c) 2010-2012 OpenStack Foundation
#
# Licensed under the Apache License, Version 2.0 (the "License");

View File

@ -1,3 +1,2 @@
python-swiftclient>=3.2.0
eventlet>=0.17.4 # MIT
six>=1.9.0

View File

@ -33,8 +33,6 @@ import eventlet.pools
from eventlet.green.httplib import CannotSendRequest
import requests.exceptions
import six
from six.moves import range
import swiftclient as client
@ -157,8 +155,7 @@ class BenchServer(object):
client, address = s.accept()
self.logger.debug('Accepting connection from %s:%s', *address)
client_file = client.makefile('rwb', 1)
if not six.PY2:
client_file = io.TextIOWrapper(client_file)
client_file = io.TextIOWrapper(client_file)
json_data = client_file.read()
conf = Values(json.loads(json_data))
@ -368,8 +365,7 @@ class DistributedBenchController(object):
s_file = s.makefile('rb', 1)
result = {}
for line in s_file:
if not six.PY2:
line = line.decode('ascii')
line = line.decode('ascii')
match = self.final_re.search(line)
if match:
g = match.groups()

View File

@ -21,8 +21,6 @@ import signal
import uuid
from optparse import OptionParser
from six.moves import range
from swiftbench.bench import (BenchController, DistributedBenchController,
create_containers, delete_containers)
from swiftbench.utils import readconf, config_true_value

View File

@ -13,11 +13,10 @@
# See the License for the specific language governing permissions and
# limitations under the License.
import six
import sys
from six.moves.configparser import ConfigParser, RawConfigParser
from six.moves.urllib.parse import urlparse
from six.moves.urllib.request import getproxies, proxy_bypass
import configparser
from urllib.parse import urlparse
from urllib.request import getproxies, proxy_bypass
# Used when reading config values
TRUE_VALUES = set(('true', '1', 'yes', 'on', 't', 'y'))
@ -41,9 +40,9 @@ def readconf(conf_path, section_name=None, log_name=None, defaults=None,
if defaults is None:
defaults = {}
if raw:
c = RawConfigParser(defaults)
c = configparser.RawConfigParser(defaults)
else:
c = ConfigParser(defaults)
c = configparser.ConfigParser(defaults)
if hasattr(conf_path, 'readline'):
c.readfp(conf_path)
else:
@ -79,7 +78,7 @@ def config_true_value(value):
Returns False otherwise.
"""
return value is True or \
(isinstance(value, six.string_types) and value.lower() in TRUE_VALUES)
(isinstance(value, str) and value.lower() in TRUE_VALUES)
def using_http_proxy(url):
@ -97,7 +96,7 @@ def get_size_bytes(value):
For example, '10k' becomes 10240, and '2M' becomes 2097152.
"""
if not isinstance(value, six.string_types):
if not isinstance(value, str):
raise TypeError
value = value.strip()
multiple = {

View File

@ -18,7 +18,7 @@ import os
import tempfile
import unittest
from six.moves import cStringIO
import io
from swiftbench import utils
@ -46,7 +46,7 @@ log_name = yarr'''
f.write(conf)
make_filename = lambda: temppath
# setup a file stream
make_fp = lambda: cStringIO(conf)
make_fp = lambda: io.StringIO(conf)
for conf_object_maker in (make_filename, make_fp):
conffile = conf_object_maker()
result = utils.readconf(conffile)
@ -92,7 +92,7 @@ log_name = %(yarr)s'''
f.write(conf)
make_filename = lambda: temppath
# setup a file stream
make_fp = lambda: cStringIO(conf)
make_fp = lambda: io.StringIO(conf)
for conf_object_maker in (make_filename, make_fp):
conffile = conf_object_maker()
result = utils.readconf(conffile, raw=True)