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:
parent
e8eb9511d2
commit
666fc883fa
@ -1,4 +1,4 @@
|
|||||||
#!/usr/bin/env python
|
#!/usr/bin/env python3
|
||||||
# Copyright (c) 2010-2012 OpenStack Foundation
|
# Copyright (c) 2010-2012 OpenStack Foundation
|
||||||
#
|
#
|
||||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
#!/usr/bin/env python
|
#!/usr/bin/env python3
|
||||||
# Copyright (c) 2010-2012 OpenStack Foundation
|
# Copyright (c) 2010-2012 OpenStack Foundation
|
||||||
#
|
#
|
||||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
@ -1,3 +1,2 @@
|
|||||||
python-swiftclient>=3.2.0
|
python-swiftclient>=3.2.0
|
||||||
eventlet>=0.17.4 # MIT
|
eventlet>=0.17.4 # MIT
|
||||||
six>=1.9.0
|
|
||||||
|
@ -33,8 +33,6 @@ import eventlet.pools
|
|||||||
from eventlet.green.httplib import CannotSendRequest
|
from eventlet.green.httplib import CannotSendRequest
|
||||||
|
|
||||||
import requests.exceptions
|
import requests.exceptions
|
||||||
import six
|
|
||||||
from six.moves import range
|
|
||||||
|
|
||||||
import swiftclient as client
|
import swiftclient as client
|
||||||
|
|
||||||
@ -157,7 +155,6 @@ class BenchServer(object):
|
|||||||
client, address = s.accept()
|
client, address = s.accept()
|
||||||
self.logger.debug('Accepting connection from %s:%s', *address)
|
self.logger.debug('Accepting connection from %s:%s', *address)
|
||||||
client_file = client.makefile('rwb', 1)
|
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()
|
json_data = client_file.read()
|
||||||
conf = Values(json.loads(json_data))
|
conf = Values(json.loads(json_data))
|
||||||
@ -368,7 +365,6 @@ class DistributedBenchController(object):
|
|||||||
s_file = s.makefile('rb', 1)
|
s_file = s.makefile('rb', 1)
|
||||||
result = {}
|
result = {}
|
||||||
for line in s_file:
|
for line in s_file:
|
||||||
if not six.PY2:
|
|
||||||
line = line.decode('ascii')
|
line = line.decode('ascii')
|
||||||
match = self.final_re.search(line)
|
match = self.final_re.search(line)
|
||||||
if match:
|
if match:
|
||||||
|
@ -21,8 +21,6 @@ import signal
|
|||||||
import uuid
|
import uuid
|
||||||
from optparse import OptionParser
|
from optparse import OptionParser
|
||||||
|
|
||||||
from six.moves import range
|
|
||||||
|
|
||||||
from swiftbench.bench import (BenchController, DistributedBenchController,
|
from swiftbench.bench import (BenchController, DistributedBenchController,
|
||||||
create_containers, delete_containers)
|
create_containers, delete_containers)
|
||||||
from swiftbench.utils import readconf, config_true_value
|
from swiftbench.utils import readconf, config_true_value
|
||||||
|
@ -13,11 +13,10 @@
|
|||||||
# See the License for the specific language governing permissions and
|
# See the License for the specific language governing permissions and
|
||||||
# limitations under the License.
|
# limitations under the License.
|
||||||
|
|
||||||
import six
|
|
||||||
import sys
|
import sys
|
||||||
from six.moves.configparser import ConfigParser, RawConfigParser
|
import configparser
|
||||||
from six.moves.urllib.parse import urlparse
|
from urllib.parse import urlparse
|
||||||
from six.moves.urllib.request import getproxies, proxy_bypass
|
from urllib.request import getproxies, proxy_bypass
|
||||||
|
|
||||||
# Used when reading config values
|
# Used when reading config values
|
||||||
TRUE_VALUES = set(('true', '1', 'yes', 'on', 't', 'y'))
|
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:
|
if defaults is None:
|
||||||
defaults = {}
|
defaults = {}
|
||||||
if raw:
|
if raw:
|
||||||
c = RawConfigParser(defaults)
|
c = configparser.RawConfigParser(defaults)
|
||||||
else:
|
else:
|
||||||
c = ConfigParser(defaults)
|
c = configparser.ConfigParser(defaults)
|
||||||
if hasattr(conf_path, 'readline'):
|
if hasattr(conf_path, 'readline'):
|
||||||
c.readfp(conf_path)
|
c.readfp(conf_path)
|
||||||
else:
|
else:
|
||||||
@ -79,7 +78,7 @@ def config_true_value(value):
|
|||||||
Returns False otherwise.
|
Returns False otherwise.
|
||||||
"""
|
"""
|
||||||
return value is True or \
|
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):
|
def using_http_proxy(url):
|
||||||
@ -97,7 +96,7 @@ def get_size_bytes(value):
|
|||||||
|
|
||||||
For example, '10k' becomes 10240, and '2M' becomes 2097152.
|
For example, '10k' becomes 10240, and '2M' becomes 2097152.
|
||||||
"""
|
"""
|
||||||
if not isinstance(value, six.string_types):
|
if not isinstance(value, str):
|
||||||
raise TypeError
|
raise TypeError
|
||||||
value = value.strip()
|
value = value.strip()
|
||||||
multiple = {
|
multiple = {
|
||||||
|
@ -18,7 +18,7 @@ import os
|
|||||||
import tempfile
|
import tempfile
|
||||||
import unittest
|
import unittest
|
||||||
|
|
||||||
from six.moves import cStringIO
|
import io
|
||||||
|
|
||||||
from swiftbench import utils
|
from swiftbench import utils
|
||||||
|
|
||||||
@ -46,7 +46,7 @@ log_name = yarr'''
|
|||||||
f.write(conf)
|
f.write(conf)
|
||||||
make_filename = lambda: temppath
|
make_filename = lambda: temppath
|
||||||
# setup a file stream
|
# setup a file stream
|
||||||
make_fp = lambda: cStringIO(conf)
|
make_fp = lambda: io.StringIO(conf)
|
||||||
for conf_object_maker in (make_filename, make_fp):
|
for conf_object_maker in (make_filename, make_fp):
|
||||||
conffile = conf_object_maker()
|
conffile = conf_object_maker()
|
||||||
result = utils.readconf(conffile)
|
result = utils.readconf(conffile)
|
||||||
@ -92,7 +92,7 @@ log_name = %(yarr)s'''
|
|||||||
f.write(conf)
|
f.write(conf)
|
||||||
make_filename = lambda: temppath
|
make_filename = lambda: temppath
|
||||||
# setup a file stream
|
# setup a file stream
|
||||||
make_fp = lambda: cStringIO(conf)
|
make_fp = lambda: io.StringIO(conf)
|
||||||
for conf_object_maker in (make_filename, make_fp):
|
for conf_object_maker in (make_filename, make_fp):
|
||||||
conffile = conf_object_maker()
|
conffile = conf_object_maker()
|
||||||
result = utils.readconf(conffile, raw=True)
|
result = utils.readconf(conffile, raw=True)
|
||||||
|
Loading…
Reference in New Issue
Block a user