Drop use of six
Change-Id: I7b1fd3412b815d88b6d54178566f4089433f98ff
This commit is contained in:
parent
cb40fac972
commit
88798e9ad8
@ -43,7 +43,6 @@ PyYAML==3.12
|
||||
reno==2.5.0
|
||||
requests==2.14.2
|
||||
rfc3986==0.3.1
|
||||
six==1.10.0
|
||||
smmap==0.9.0
|
||||
snowballstemmer==1.2.1
|
||||
Sphinx==1.8.0
|
||||
|
@ -27,7 +27,6 @@ from oslo_concurrency import lockutils
|
||||
from oslo_context import context
|
||||
from oslo_utils import excutils
|
||||
from oslo_utils import reflection
|
||||
import six
|
||||
|
||||
from oslo_vmware._i18n import _
|
||||
from oslo_vmware.common import loopingcall
|
||||
@ -339,7 +338,7 @@ class VMwareAPISession(object):
|
||||
fault = excep.fault_list[0]
|
||||
clazz = exceptions.get_fault_class(fault)
|
||||
if clazz:
|
||||
raise clazz(six.text_type(excep),
|
||||
raise clazz(str(excep),
|
||||
details=excep.details)
|
||||
raise
|
||||
|
||||
@ -375,7 +374,7 @@ class VMwareAPISession(object):
|
||||
except exceptions.VimException as ex:
|
||||
LOG.debug("Error: %(error)s occurred while checking whether the "
|
||||
"current session: %(session)s is active.",
|
||||
{'error': six.text_type(ex),
|
||||
{'error': str(ex),
|
||||
'session': _trunc_id(self._session_id)})
|
||||
|
||||
return is_active
|
||||
|
@ -19,8 +19,6 @@ Exception definitions.
|
||||
|
||||
import logging
|
||||
|
||||
import six
|
||||
|
||||
from oslo_vmware._i18n import _
|
||||
|
||||
LOG = logging.getLogger(__name__)
|
||||
@ -53,11 +51,7 @@ class VMwareDriverException(Exception):
|
||||
"""
|
||||
msg_fmt = _("An unknown exception occurred.")
|
||||
|
||||
if six.PY2:
|
||||
__str__ = lambda self: six.text_type(self).encode('utf8')
|
||||
__unicode__ = lambda self: self.description
|
||||
else:
|
||||
__str__ = lambda self: self.description
|
||||
__str__ = lambda self: self.description
|
||||
|
||||
def __init__(self, message=None, details=None, **kwargs):
|
||||
|
||||
@ -80,7 +74,7 @@ class VMwareDriverException(Exception):
|
||||
# kwargs doesn't match a variable in the message
|
||||
# log the issue and the kwargs
|
||||
LOG.exception('Exception in string format operation')
|
||||
for name, value in six.iteritems(kwargs):
|
||||
for name, value in kwargs.items():
|
||||
LOG.error("%(name)s: %(value)s",
|
||||
{'name': name, 'value': value})
|
||||
# at least get the core message out if something happened
|
||||
@ -98,9 +92,9 @@ class VMwareDriverException(Exception):
|
||||
# NOTE(jecarey): self.msg and self.cause may be i18n objects
|
||||
# that do not support str or concatenation, but can be used
|
||||
# as replacement text.
|
||||
descr = six.text_type(self.msg)
|
||||
descr = str(self.msg)
|
||||
if self.cause:
|
||||
descr += '\nCause: ' + six.text_type(self.cause)
|
||||
descr += '\nCause: ' + str(self.cause)
|
||||
return descr
|
||||
|
||||
|
||||
@ -154,7 +148,7 @@ class VimFaultException(VimException):
|
||||
if self.details:
|
||||
# details may contain non-ASCII values
|
||||
details = '{%s}' % ', '.join(["'%s': '%s'" % (k, v) for k, v in
|
||||
six.iteritems(self.details)])
|
||||
self.details.items()])
|
||||
descr += '\nDetails: ' + details
|
||||
return descr
|
||||
|
||||
@ -306,7 +300,7 @@ def translate_fault(localized_method_fault, excep_msg=None):
|
||||
"""
|
||||
try:
|
||||
if not excep_msg:
|
||||
excep_msg = six.text_type(localized_method_fault.localizedMessage)
|
||||
excep_msg = str(localized_method_fault.localizedMessage)
|
||||
name = localized_method_fault.fault.__class__.__name__
|
||||
fault_class = get_fault_class(name)
|
||||
if fault_class:
|
||||
|
@ -21,7 +21,6 @@ import logging
|
||||
import tarfile
|
||||
|
||||
from eventlet import timeout
|
||||
import six
|
||||
|
||||
from oslo_utils import units
|
||||
from oslo_vmware._i18n import _
|
||||
@ -330,7 +329,7 @@ def upload_image(context, timeout_secs, image_service, image_id, owner_id,
|
||||
LOG.warning("The keyword argument 'image_version' is deprecated "
|
||||
"and will be ignored in the next release.")
|
||||
|
||||
image_ver = six.text_type(kwargs.get('image_version'))
|
||||
image_ver = str(kwargs.get('image_version'))
|
||||
image_metadata = {'disk_format': 'vmdk',
|
||||
'name': kwargs.get('image_name'),
|
||||
'properties': {'vmware_image_version': image_ver,
|
||||
|
@ -17,8 +17,8 @@ import posixpath
|
||||
import random
|
||||
import re
|
||||
|
||||
import six.moves.http_client as httplib
|
||||
import six.moves.urllib.parse as urlparse
|
||||
import http.client as httplib
|
||||
import urllib.parse as urlparse
|
||||
|
||||
from oslo_vmware._i18n import _
|
||||
from oslo_vmware import constants
|
||||
|
@ -23,8 +23,8 @@ Refer http://goo.gl/GR2o6U for more details.
|
||||
import logging
|
||||
import os
|
||||
|
||||
import six.moves.urllib.parse as urlparse
|
||||
import six.moves.urllib.request as urllib
|
||||
import urllib.parse as urlparse
|
||||
import urllib.request as urllib
|
||||
|
||||
from oslo_vmware import service
|
||||
from oslo_vmware import vim_util
|
||||
|
@ -28,8 +28,7 @@ import time
|
||||
from oslo_utils import excutils
|
||||
from oslo_utils import netutils
|
||||
import requests
|
||||
import six
|
||||
import six.moves.urllib.parse as urlparse
|
||||
import urllib.parse as urlparse
|
||||
from urllib3 import connection as httplib
|
||||
|
||||
from oslo_vmware._i18n import _
|
||||
@ -135,7 +134,7 @@ class FileHandle(object):
|
||||
self._build_vim_cookie_header(cookies)})
|
||||
if content_type:
|
||||
headers.update({'Content-Type': content_type})
|
||||
for key, value in six.iteritems(headers):
|
||||
for key, value in headers.items():
|
||||
conn.putheader(key, value)
|
||||
conn.endheaders()
|
||||
return conn
|
||||
|
@ -17,6 +17,8 @@
|
||||
Common classes that provide access to vSphere services.
|
||||
"""
|
||||
|
||||
import http.client as httplib
|
||||
import io
|
||||
import logging
|
||||
import os
|
||||
|
||||
@ -24,8 +26,6 @@ import netaddr
|
||||
from oslo_utils import timeutils
|
||||
from oslo_utils import uuidutils
|
||||
import requests
|
||||
import six
|
||||
import six.moves.http_client as httplib
|
||||
import suds
|
||||
from suds import cache
|
||||
from suds import client
|
||||
@ -96,7 +96,7 @@ class ServiceMessagePlugin(plugin.MessagePlugin):
|
||||
context.envelope.walk(self.add_attribute_for_value)
|
||||
|
||||
|
||||
class Response(six.BytesIO):
|
||||
class Response(io.BytesIO):
|
||||
"""Response with an input stream as source."""
|
||||
|
||||
def __init__(self, stream, status=200, headers=None):
|
||||
@ -104,7 +104,7 @@ class Response(six.BytesIO):
|
||||
self.headers = headers or {}
|
||||
self.reason = requests.status_codes._codes.get(
|
||||
status, [''])[0].upper().replace('_', ' ')
|
||||
six.BytesIO.__init__(self, stream)
|
||||
io.BytesIO.__init__(self, stream)
|
||||
|
||||
@property
|
||||
def _original_response(self):
|
||||
@ -115,7 +115,7 @@ class Response(six.BytesIO):
|
||||
return self
|
||||
|
||||
def read(self, chunk_size, **kwargs):
|
||||
return six.BytesIO.read(self, chunk_size)
|
||||
return io.BytesIO.read(self, chunk_size)
|
||||
|
||||
def info(self):
|
||||
return self
|
||||
@ -173,7 +173,7 @@ class RequestsTransport(transport.Transport):
|
||||
|
||||
def open(self, request):
|
||||
resp = self.session.get(request.url, verify=self.verify)
|
||||
return six.BytesIO(resp.content)
|
||||
return io.BytesIO(resp.content)
|
||||
|
||||
def send(self, request):
|
||||
resp = self.session.post(request.url,
|
||||
@ -414,13 +414,13 @@ class Service(object):
|
||||
|
||||
# Socket errors which need special handling; some of these
|
||||
# might be caused by server API call overload.
|
||||
if (six.text_type(excep).find(ADDRESS_IN_USE_ERROR) != -1 or
|
||||
six.text_type(excep).find(CONN_ABORT_ERROR)) != -1:
|
||||
if (str(excep).find(ADDRESS_IN_USE_ERROR) != -1 or
|
||||
str(excep).find(CONN_ABORT_ERROR)) != -1:
|
||||
raise exceptions.VimSessionOverLoadException(
|
||||
_("Socket error in %s.") % attr_name, excep)
|
||||
# Type error which needs special handling; it might be caused
|
||||
# by server API call overload.
|
||||
elif six.text_type(excep).find(RESP_NOT_XML_ERROR) != -1:
|
||||
elif str(excep).find(RESP_NOT_XML_ERROR) != -1:
|
||||
raise exceptions.VimSessionOverLoadException(
|
||||
_("Type error in %s.") % attr_name, excep)
|
||||
else:
|
||||
|
@ -14,7 +14,7 @@
|
||||
|
||||
import mock
|
||||
from oslo_utils import units
|
||||
import six.moves.urllib.parse as urlparse
|
||||
import urllib.parse as urlparse
|
||||
|
||||
from oslo_vmware import constants
|
||||
from oslo_vmware.objects import datastore
|
||||
@ -429,7 +429,7 @@ class DatastoreURLTestCase(base.TestCase):
|
||||
ds_url = datastore.DatastoreURL.urlparse(url)
|
||||
self.assertEqual(path, ds_url.path)
|
||||
|
||||
@mock.patch('six.moves.http_client.HTTPSConnection')
|
||||
@mock.patch('http.client.HTTPSConnection')
|
||||
def test_connect(self, mock_conn):
|
||||
dc_path = 'datacenter-1'
|
||||
ds_name = 'datastore-1'
|
||||
|
@ -21,7 +21,6 @@ Unit tests for session management and API invocation classes.
|
||||
from datetime import datetime
|
||||
from eventlet import greenthread
|
||||
import mock
|
||||
import six
|
||||
import suds
|
||||
|
||||
from oslo_context import context
|
||||
@ -334,7 +333,7 @@ class VMwareAPISessionTest(base.TestCase):
|
||||
expected_str = "%s\nFaults: %s\nDetails: %s" % (fault_string,
|
||||
fault_list,
|
||||
details_str)
|
||||
self.assertEqual(expected_str, six.text_type(e))
|
||||
self.assertEqual(expected_str, str(e))
|
||||
self.assertEqual(details, e.details)
|
||||
|
||||
def test_invoke_api_with_empty_response(self):
|
||||
@ -598,7 +597,7 @@ class VMwareAPISessionTest(base.TestCase):
|
||||
ctx)
|
||||
|
||||
def test_poll_task_well_known_exceptions(self):
|
||||
for k, v in six.iteritems(exceptions._fault_classes_registry):
|
||||
for k, v in exceptions._fault_classes_registry.items():
|
||||
self._poll_task_well_known_exceptions(k, v)
|
||||
|
||||
def test_poll_task_unknown_exception(self):
|
||||
@ -607,7 +606,7 @@ class VMwareAPISessionTest(base.TestCase):
|
||||
'RuntimeFault': exceptions.VimFaultException
|
||||
}
|
||||
|
||||
for k, v in six.iteritems(_unknown_exceptions):
|
||||
for k, v in _unknown_exceptions.items():
|
||||
self._poll_task_well_known_exceptions(k, v)
|
||||
|
||||
def test_update_pbm_wsdl_loc(self):
|
||||
|
@ -17,8 +17,9 @@
|
||||
Unit tests for functions and classes for image transfer.
|
||||
"""
|
||||
|
||||
import io
|
||||
|
||||
import mock
|
||||
import six
|
||||
|
||||
from oslo_vmware import exceptions
|
||||
from oslo_vmware import image_transfer
|
||||
@ -30,7 +31,7 @@ class ImageTransferUtilityTest(base.TestCase):
|
||||
|
||||
def test_start_transfer(self):
|
||||
data = b'image-data-here'
|
||||
read_handle = six.BytesIO(data)
|
||||
read_handle = io.BytesIO(data)
|
||||
write_handle = mock.Mock()
|
||||
image_transfer._start_transfer(read_handle, write_handle, None)
|
||||
write_handle.write.assert_called_once_with(data)
|
||||
@ -400,7 +401,7 @@ class ImageTransferUtilityTest(base.TestCase):
|
||||
file_path,
|
||||
image_size)
|
||||
|
||||
ver_str = six.text_type(image_version)
|
||||
ver_str = str(image_version)
|
||||
image_metadata = {'disk_format': 'vmdk',
|
||||
'name': image_name,
|
||||
'properties': {'vmware_image_version': ver_str,
|
||||
|
@ -20,8 +20,8 @@ Unit tests for PBM utility methods.
|
||||
import os
|
||||
|
||||
import mock
|
||||
import six.moves.urllib.parse as urlparse
|
||||
import six.moves.urllib.request as urllib
|
||||
import urllib.parse as urlparse
|
||||
import urllib.request as urllib
|
||||
|
||||
from oslo_vmware import pbm
|
||||
from oslo_vmware.tests import base
|
||||
|
@ -21,7 +21,6 @@ import ssl
|
||||
|
||||
import mock
|
||||
import requests
|
||||
import six
|
||||
|
||||
from oslo_vmware import exceptions
|
||||
from oslo_vmware import rw_handles
|
||||
@ -414,7 +413,7 @@ class ImageReadHandleTest(base.TestCase):
|
||||
max_items = 10
|
||||
item = [1] * 10
|
||||
|
||||
class ImageReadIterator(six.Iterator):
|
||||
class ImageReadIterator(object):
|
||||
|
||||
def __init__(self):
|
||||
self.num_items = 0
|
||||
|
@ -13,13 +13,12 @@
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
import http.client as httplib
|
||||
import io
|
||||
|
||||
import ddt
|
||||
import mock
|
||||
import requests
|
||||
import six
|
||||
import six.moves.http_client as httplib
|
||||
import suds
|
||||
|
||||
from oslo_vmware import exceptions
|
||||
@ -503,10 +502,7 @@ class RequestsTransportTest(base.TestCase):
|
||||
def readinto_mock(buf):
|
||||
buf[0:] = data
|
||||
|
||||
if six.PY3:
|
||||
builtin_open = 'builtins.open'
|
||||
else:
|
||||
builtin_open = '__builtin__.open'
|
||||
builtin_open = 'builtins.open'
|
||||
open_mock = mock.MagicMock(name='file_handle',
|
||||
spec=open)
|
||||
file_spec = list(set(dir(io.TextIOWrapper)).union(
|
||||
|
@ -6,7 +6,6 @@ pbr!=2.1.0,>=2.0.0 # Apache-2.0
|
||||
|
||||
stevedore>=1.20.0 # Apache-2.0
|
||||
netaddr>=0.7.18 # BSD
|
||||
six>=1.10.0 # MIT
|
||||
|
||||
oslo.i18n>=3.15.3 # Apache-2.0
|
||||
oslo.utils>=3.33.0 # Apache-2.0
|
||||
|
Loading…
Reference in New Issue
Block a user