Remove six from project dependencies
Change-Id: I07ef144ce7af6d14004530f88318824e1545c4b9
This commit is contained in:
parent
f7fd956ed2
commit
630f4ad730
@ -22,7 +22,6 @@ python-novaclient>=17.2.1 # Apache-2.0
|
||||
python-octaviaclient>=2.2.0 # Apache-2.0
|
||||
python-openstackclient>=5.4.0 # Apache-2.0
|
||||
PyYAML>=5.4.1 # MIT
|
||||
six>=1.15.0 # MIT
|
||||
sshtunnel>=0.3.1 # MIT
|
||||
testtools>=2.4.0 # MIT
|
||||
validations-libs>=1.1.0 # Apache-2.0
|
||||
|
@ -18,7 +18,6 @@ import itertools
|
||||
|
||||
import fixtures
|
||||
from oslo_log import log
|
||||
import six
|
||||
import testtools
|
||||
from testtools import content
|
||||
|
||||
@ -97,7 +96,7 @@ def get_text_to_get_bytes(get_text):
|
||||
def get_bytes():
|
||||
text = get_text()
|
||||
if text:
|
||||
if isinstance(text, six.string_types):
|
||||
if isinstance(text, str):
|
||||
yield text.encode(errors='ignore')
|
||||
else:
|
||||
for t in text:
|
||||
|
@ -21,7 +21,6 @@ import typing
|
||||
|
||||
import fixtures
|
||||
from oslo_log import log
|
||||
import six
|
||||
import testtools
|
||||
|
||||
import tobiko
|
||||
@ -88,7 +87,7 @@ def get_fixture_name(obj):
|
||||
|
||||
def get_fixture_class(obj):
|
||||
'''Get fixture class'''
|
||||
if isinstance(obj, six.string_types):
|
||||
if isinstance(obj, str):
|
||||
obj = tobiko.load_object(obj)
|
||||
|
||||
if not inspect.isclass(obj):
|
||||
@ -161,7 +160,7 @@ def cleanup_fixture(obj, fixture_id=None, manager=None):
|
||||
|
||||
def get_name_and_object(obj):
|
||||
'''Get (name, obj) tuple identified by given :param obj:'''
|
||||
if isinstance(obj, six.string_types):
|
||||
if isinstance(obj, str):
|
||||
return obj, tobiko.load_object(obj)
|
||||
else:
|
||||
return get_object_name(obj), obj
|
||||
@ -219,8 +218,9 @@ def get_required_fixtures(obj):
|
||||
if required_names is None:
|
||||
if is_test_method(obj):
|
||||
# Get fixtures from default values that are fixtures
|
||||
defaults = getattr(obj, '__defaults__', None) or []
|
||||
required = {default
|
||||
for default in six.get_function_defaults(obj) or []
|
||||
for default in defaults
|
||||
if is_fixture(default)}
|
||||
|
||||
elif inspect.isclass(obj):
|
||||
@ -312,7 +312,7 @@ def get_fixture_id(obj: typing.Any) -> typing.Any:
|
||||
|
||||
def get_object_name(obj):
|
||||
'''Gets a fully qualified name for given :param obj:'''
|
||||
if isinstance(obj, six.string_types):
|
||||
if isinstance(obj, str):
|
||||
return obj
|
||||
|
||||
name = getattr(obj, '__tobiko_fixture_name__', None)
|
||||
@ -326,25 +326,9 @@ def get_object_name(obj):
|
||||
|
||||
module = inspect.getmodule(obj).__name__
|
||||
|
||||
if six.PY2:
|
||||
# Below code is only for old Python versions
|
||||
if inspect.isclass(obj):
|
||||
# This doesn't work for nested classes
|
||||
return module + '.' + obj.__name__
|
||||
|
||||
method_class = getattr(obj, 'im_class', None)
|
||||
if method_class:
|
||||
# This doesn't work for nested classes
|
||||
return module + '.' + method_class.__name__ + '.' + obj.__name__
|
||||
|
||||
if inspect.isfunction(obj):
|
||||
return module + '.' + obj.func_name
|
||||
|
||||
else:
|
||||
# Only Python 3 defines __qualname__
|
||||
name = getattr(obj, '__qualname__', None)
|
||||
if name:
|
||||
return module + '.' + name
|
||||
name = getattr(obj, '__qualname__', None)
|
||||
if name:
|
||||
return module + '.' + name
|
||||
|
||||
msg = "Unable to get fixture name from object {!r}".format(obj)
|
||||
raise TypeError(msg)
|
||||
|
@ -21,7 +21,6 @@ import typing
|
||||
from abc import ABC
|
||||
|
||||
import netaddr
|
||||
import six
|
||||
from oslo_log import log
|
||||
|
||||
import tobiko
|
||||
@ -497,7 +496,7 @@ class SameHostServerStackFixture(PeerServerStackFixture, abc.ABC):
|
||||
|
||||
|
||||
def as_str(text):
|
||||
if isinstance(text, six.string_types):
|
||||
if isinstance(text, str):
|
||||
return text
|
||||
else:
|
||||
return text.decode()
|
||||
|
@ -16,12 +16,11 @@ from __future__ import absolute_import
|
||||
import collections
|
||||
import re
|
||||
import typing
|
||||
from urllib import parse
|
||||
import weakref
|
||||
|
||||
import netaddr
|
||||
from oslo_log import log
|
||||
import six
|
||||
from six.moves.urllib import parse
|
||||
|
||||
import tobiko
|
||||
from tobiko.shell import files
|
||||
@ -387,7 +386,7 @@ class OpenStackTopology(tobiko.SharedFixture):
|
||||
name = name or (hostname and node_name_from_hostname(hostname))
|
||||
details = {}
|
||||
if name:
|
||||
tobiko.check_valid_type(name, six.string_types)
|
||||
tobiko.check_valid_type(name, str)
|
||||
details['name'] = name
|
||||
try:
|
||||
return self._names[name]
|
||||
|
@ -19,7 +19,6 @@ import collections
|
||||
import enum
|
||||
|
||||
from oslo_log import log
|
||||
import six
|
||||
|
||||
import tobiko
|
||||
from tobiko.shell.sh import _exception
|
||||
@ -29,7 +28,7 @@ from tobiko.shell.sh import _process
|
||||
LOG = log.getLogger(__name__)
|
||||
|
||||
|
||||
DATA_TYPES = six.string_types + (six.binary_type, six.text_type)
|
||||
DATA_TYPES = (str, bytes)
|
||||
|
||||
|
||||
@enum.unique
|
||||
|
@ -19,7 +19,7 @@ import io
|
||||
import select
|
||||
|
||||
from oslo_log import log
|
||||
import six
|
||||
|
||||
|
||||
LOG = log.getLogger(__name__)
|
||||
|
||||
@ -58,7 +58,7 @@ class ShellIOBase(io.IOBase):
|
||||
if not data:
|
||||
return ''
|
||||
|
||||
if isinstance(data, six.string_types):
|
||||
if isinstance(data, str):
|
||||
return data
|
||||
|
||||
return data.decode()
|
||||
@ -124,7 +124,7 @@ class ShellWritable(ShellIOBase):
|
||||
return True
|
||||
|
||||
def write(self, data):
|
||||
if not isinstance(data, six.binary_type):
|
||||
if not isinstance(data, bytes):
|
||||
data = data.encode()
|
||||
witten_bytes = self.delegate.write(data)
|
||||
if witten_bytes is None:
|
||||
|
@ -29,7 +29,6 @@ import netaddr
|
||||
from oslo_log import log
|
||||
import paramiko
|
||||
from paramiko import common
|
||||
import six
|
||||
|
||||
import tobiko
|
||||
from tobiko.shell.ssh import _config
|
||||
@ -76,7 +75,7 @@ def positive_int(value):
|
||||
|
||||
|
||||
def get_key_filename(value):
|
||||
if isinstance(value, six.string_types):
|
||||
if isinstance(value, str):
|
||||
value = [value]
|
||||
key_filename = [tobiko.tobiko_config_path(v) for v in value]
|
||||
return [f
|
||||
@ -670,7 +669,7 @@ def ssh_proxy_sock(hostname=None, port=None, command=None, client=None,
|
||||
return None
|
||||
|
||||
# Apply connect parameters to proxy command
|
||||
if not isinstance(command, six.string_types):
|
||||
if not isinstance(command, str):
|
||||
command = subprocess.list2cmdline(command)
|
||||
if hostname:
|
||||
command = command.format(hostname=hostname, port=(port or 22))
|
||||
|
@ -17,8 +17,6 @@ from __future__ import absolute_import
|
||||
|
||||
import subprocess
|
||||
|
||||
import six
|
||||
|
||||
from tobiko.shell.ssh import _config
|
||||
|
||||
|
||||
@ -38,7 +36,7 @@ def ssh_command(host, username=None, port=None, command=None,
|
||||
host=host, config_files=config_files)
|
||||
|
||||
command = command or host_config.default.command.split()
|
||||
if isinstance(command, six.string_types):
|
||||
if isinstance(command, str):
|
||||
command = command.split()
|
||||
|
||||
hostname = host_config.hostname
|
||||
@ -56,7 +54,7 @@ def ssh_command(host, username=None, port=None, command=None,
|
||||
command += ['-i', key_filename]
|
||||
|
||||
if proxy_command:
|
||||
if not isinstance(proxy_command, six.string_types):
|
||||
if not isinstance(proxy_command, str):
|
||||
proxy_command = subprocess.list2cmdline([str(a)
|
||||
for a in proxy_command])
|
||||
options['ProxyCommand'] = proxy_command
|
||||
|
@ -18,10 +18,9 @@ from __future__ import absolute_import
|
||||
import collections
|
||||
import contextlib
|
||||
import socket
|
||||
import urllib
|
||||
|
||||
from oslo_log import log
|
||||
import six
|
||||
from six.moves import urllib
|
||||
import sshtunnel
|
||||
|
||||
import tobiko
|
||||
@ -154,7 +153,7 @@ class SSHUnixForwardHandler(sshtunnel._ForwardHandler):
|
||||
self.server.local_address)
|
||||
|
||||
remote_address = self.remote_address
|
||||
assert isinstance(remote_address, six.string_types)
|
||||
assert isinstance(remote_address, str)
|
||||
command = 'sudo nc -U "{}"'.format(remote_address)
|
||||
|
||||
chan = self.transport.open_session()
|
||||
@ -303,7 +302,7 @@ def binding_url(address):
|
||||
return 'tcp://{hostname}:{port}'.format(hostname=hostname,
|
||||
port=port)
|
||||
|
||||
elif isinstance(address, six.string_types):
|
||||
elif isinstance(address, str):
|
||||
return 'unix://{path}'.format(path=address)
|
||||
|
||||
raise TypeError('Invalid address type: {!r}'.format(address))
|
||||
|
@ -17,7 +17,6 @@ import os
|
||||
|
||||
import netaddr
|
||||
import pandas as pd
|
||||
import six
|
||||
import testtools
|
||||
|
||||
from tobiko import config
|
||||
@ -71,7 +70,7 @@ class OvercloudNovaApiTest(testtools.TestCase):
|
||||
host_config = tobiko.setup_fixture(
|
||||
tripleo.overcloud_host_config(hostname=hostname))
|
||||
self.assertEqual(hostname, host_config.host)
|
||||
self.assertIsInstance(host_config.hostname, six.string_types)
|
||||
self.assertIsInstance(host_config.hostname, str)
|
||||
netaddr.IPAddress(host_config.hostname)
|
||||
self.assertEqual(CONF.tobiko.tripleo.overcloud_ssh_port,
|
||||
host_config.port)
|
||||
|
@ -13,8 +13,6 @@
|
||||
# under the License.
|
||||
from __future__ import absolute_import
|
||||
|
||||
import six
|
||||
|
||||
from tobiko import config
|
||||
from tobiko.tests import unit
|
||||
|
||||
@ -26,8 +24,7 @@ TIPLEO_CONF = CONF.tobiko.tripleo
|
||||
class TripleoConfigTest(unit.TobikoUnitTest):
|
||||
|
||||
def test_ssh_key_filename(self):
|
||||
self.assertIsInstance(TIPLEO_CONF.undercloud_ssh_key_filename,
|
||||
six.string_types)
|
||||
self.assertIsInstance(TIPLEO_CONF.undercloud_ssh_key_filename, str)
|
||||
|
||||
|
||||
class UndercloudConfigTest(unit.TobikoUnitTest):
|
||||
@ -35,21 +32,21 @@ class UndercloudConfigTest(unit.TobikoUnitTest):
|
||||
def test_undercloud_ssh_hostname(self):
|
||||
value = TIPLEO_CONF.undercloud_ssh_hostname
|
||||
if value is not None:
|
||||
self.assertIsInstance(value, six.string_types)
|
||||
self.assertIsInstance(value, str)
|
||||
|
||||
def test_undercloud_ssh_port(self):
|
||||
value = TIPLEO_CONF.undercloud_ssh_port
|
||||
if value is not None:
|
||||
self.assertIsInstance(value, int)
|
||||
self.assertIn(value, six.moves.range(1, 2 ** 16))
|
||||
self.assertGreater(value, 0)
|
||||
self.assertLess(value, 2 ** 16)
|
||||
|
||||
def test_undercloud_ssh_username(self):
|
||||
self.assertIsInstance(TIPLEO_CONF.undercloud_ssh_username,
|
||||
six.string_types)
|
||||
self.assertIsInstance(TIPLEO_CONF.undercloud_ssh_username, str)
|
||||
|
||||
def test_undercloud_rcfile(self):
|
||||
for rcfile in TIPLEO_CONF.undercloud_rcfile:
|
||||
self.assertIsInstance(rcfile, six.string_types)
|
||||
self.assertIsInstance(rcfile, str)
|
||||
|
||||
|
||||
class OvercloudConfigTest(unit.TobikoUnitTest):
|
||||
@ -58,12 +55,12 @@ class OvercloudConfigTest(unit.TobikoUnitTest):
|
||||
value = TIPLEO_CONF.overcloud_ssh_port
|
||||
if value is not None:
|
||||
self.assertIsInstance(value, int)
|
||||
self.assertIn(value, six.moves.range(1, 2 ** 16))
|
||||
self.assertGreater(value, 0)
|
||||
self.assertLess(value, 2 ** 16)
|
||||
|
||||
def test_overcloud_ssh_username(self):
|
||||
self.assertIsInstance(TIPLEO_CONF.overcloud_ssh_username,
|
||||
six.string_types)
|
||||
self.assertIsInstance(TIPLEO_CONF.overcloud_ssh_username, str)
|
||||
|
||||
def test_overcloud_rcfile(self):
|
||||
for rcfile in TIPLEO_CONF.overcloud_rcfile:
|
||||
self.assertIsInstance(rcfile, six.string_types)
|
||||
self.assertIsInstance(rcfile, str)
|
||||
|
@ -17,7 +17,6 @@ import io
|
||||
import os
|
||||
|
||||
from oslo_log import log
|
||||
import six
|
||||
|
||||
import tobiko
|
||||
from tobiko import config
|
||||
@ -199,7 +198,7 @@ class OvercloudHostConfig(tobiko.SharedFixture):
|
||||
self.server = server
|
||||
if self.host is None:
|
||||
self.host = server.name
|
||||
tobiko.check_valid_type(self.host, six.string_types)
|
||||
tobiko.check_valid_type(self.host, str)
|
||||
self._connect_parameters = ssh.gather_ssh_connect_parameters(**kwargs)
|
||||
|
||||
def setup_fixture(self):
|
||||
|
@ -1,10 +1,10 @@
|
||||
from __future__ import absolute_import
|
||||
|
||||
import io
|
||||
import time
|
||||
|
||||
from oslo_log import log
|
||||
import pandas
|
||||
import six
|
||||
|
||||
import tobiko
|
||||
from tobiko.tripleo import overcloud
|
||||
@ -53,7 +53,7 @@ def get_pcs_resources_table(timeout=720, interval=2):
|
||||
expect_exit_status=None).stdout
|
||||
# remove the first column when it only includes '*' characters
|
||||
output = output.replace('*', '').strip()
|
||||
stream = six.StringIO(output)
|
||||
stream = io.StringIO(output)
|
||||
table = pandas.read_csv(stream, delim_whitespace=True, header=None)
|
||||
table.columns = ['resource', 'resource_type', 'resource_state',
|
||||
'overcloud_node']
|
||||
|
@ -1,11 +1,11 @@
|
||||
from __future__ import absolute_import
|
||||
|
||||
import io
|
||||
import re
|
||||
import time
|
||||
|
||||
from oslo_log import log
|
||||
import pandas
|
||||
import six
|
||||
|
||||
import tobiko
|
||||
from tobiko.openstack import neutron
|
||||
@ -53,7 +53,7 @@ root | 11| 2| 0.0| 0|00:00:05|migration/0 |[migration/0]
|
||||
"\"DELIM%z\" -o \"DELIM%x\" -o \"DELIM%c\" -o \"DELIM%a\" |grep -v "
|
||||
"ps|sed 's/\"/''/g'",
|
||||
ssh_client=ssh_client).stdout
|
||||
stream = six.StringIO(output)
|
||||
stream = io.StringIO(output)
|
||||
table = pandas.read_csv(stream, sep='DELIM', header=None, skiprows=1)
|
||||
table.replace(to_replace=' ', value="", regex=True, inplace=True)
|
||||
table.columns = ['USER', 'PID', 'PPID', 'CPU', 'VSZ', 'TIME', 'PROCESS',
|
||||
|
Loading…
Reference in New Issue
Block a user