Merge "Python3: replace 'unicode' with 'six.text_type'"
This commit is contained in:
commit
3e57e83c6f
@ -20,6 +20,7 @@ from neutronclient.v2_0 import client
|
|||||||
from oslo_config import cfg
|
from oslo_config import cfg
|
||||||
from oslo_log import log as logging
|
from oslo_log import log as logging
|
||||||
import oslo_messaging
|
import oslo_messaging
|
||||||
|
import six
|
||||||
import six.moves.urllib.parse as urlparse
|
import six.moves.urllib.parse as urlparse
|
||||||
import webob
|
import webob
|
||||||
|
|
||||||
@ -116,7 +117,8 @@ class MetadataProxyHandler(object):
|
|||||||
LOG.exception(_LE("Unexpected error."))
|
LOG.exception(_LE("Unexpected error."))
|
||||||
msg = _('An unknown error has occurred. '
|
msg = _('An unknown error has occurred. '
|
||||||
'Please try your request again.')
|
'Please try your request again.')
|
||||||
return webob.exc.HTTPInternalServerError(explanation=unicode(msg))
|
explanation = six.text_type(msg)
|
||||||
|
return webob.exc.HTTPInternalServerError(explanation=explanation)
|
||||||
|
|
||||||
def _get_ports_from_server(self, router_id=None, ip_address=None,
|
def _get_ports_from_server(self, router_id=None, ip_address=None,
|
||||||
networks=None):
|
networks=None):
|
||||||
@ -257,7 +259,8 @@ class MetadataProxyHandler(object):
|
|||||||
'Remote metadata server experienced an internal server error.'
|
'Remote metadata server experienced an internal server error.'
|
||||||
)
|
)
|
||||||
LOG.warn(msg)
|
LOG.warn(msg)
|
||||||
return webob.exc.HTTPInternalServerError(explanation=unicode(msg))
|
explanation = six.text_type(msg)
|
||||||
|
return webob.exc.HTTPInternalServerError(explanation=explanation)
|
||||||
else:
|
else:
|
||||||
raise Exception(_('Unexpected response code: %s') % resp.status)
|
raise Exception(_('Unexpected response code: %s') % resp.status)
|
||||||
|
|
||||||
|
@ -15,6 +15,7 @@
|
|||||||
import httplib2
|
import httplib2
|
||||||
from oslo_config import cfg
|
from oslo_config import cfg
|
||||||
from oslo_log import log as logging
|
from oslo_log import log as logging
|
||||||
|
import six
|
||||||
import six.moves.urllib.parse as urlparse
|
import six.moves.urllib.parse as urlparse
|
||||||
import webob
|
import webob
|
||||||
|
|
||||||
@ -56,7 +57,8 @@ class NetworkMetadataProxyHandler(object):
|
|||||||
LOG.exception(_LE("Unexpected error."))
|
LOG.exception(_LE("Unexpected error."))
|
||||||
msg = _('An unknown error has occurred. '
|
msg = _('An unknown error has occurred. '
|
||||||
'Please try your request again.')
|
'Please try your request again.')
|
||||||
return webob.exc.HTTPInternalServerError(explanation=unicode(msg))
|
explanation = six.text_type(msg)
|
||||||
|
return webob.exc.HTTPInternalServerError(explanation=explanation)
|
||||||
|
|
||||||
def _proxy_request(self, remote_address, method, path_info,
|
def _proxy_request(self, remote_address, method, path_info,
|
||||||
query_string, body):
|
query_string, body):
|
||||||
@ -103,7 +105,8 @@ class NetworkMetadataProxyHandler(object):
|
|||||||
'Remote metadata server experienced an internal server error.'
|
'Remote metadata server experienced an internal server error.'
|
||||||
)
|
)
|
||||||
LOG.debug(msg)
|
LOG.debug(msg)
|
||||||
return webob.exc.HTTPInternalServerError(explanation=unicode(msg))
|
explanation = six.text_type(msg)
|
||||||
|
return webob.exc.HTTPInternalServerError(explanation=explanation)
|
||||||
else:
|
else:
|
||||||
raise Exception(_('Unexpected response code: %s') % resp.status)
|
raise Exception(_('Unexpected response code: %s') % resp.status)
|
||||||
|
|
||||||
|
@ -506,7 +506,8 @@ class ExtensionManager(object):
|
|||||||
LOG.debug('Ext namespace: %s', extension.get_namespace())
|
LOG.debug('Ext namespace: %s', extension.get_namespace())
|
||||||
LOG.debug('Ext updated: %s', extension.get_updated())
|
LOG.debug('Ext updated: %s', extension.get_updated())
|
||||||
except AttributeError as ex:
|
except AttributeError as ex:
|
||||||
LOG.exception(_LE("Exception loading extension: %s"), unicode(ex))
|
LOG.exception(_LE("Exception loading extension: %s"),
|
||||||
|
six.text_type(ex))
|
||||||
return False
|
return False
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
@ -18,6 +18,7 @@ Neutron base exception handling.
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
from oslo_utils import excutils
|
from oslo_utils import excutils
|
||||||
|
import six
|
||||||
|
|
||||||
|
|
||||||
class NeutronException(Exception):
|
class NeutronException(Exception):
|
||||||
@ -40,6 +41,7 @@ class NeutronException(Exception):
|
|||||||
# at least get the core message out if something happened
|
# at least get the core message out if something happened
|
||||||
super(NeutronException, self).__init__(self.message)
|
super(NeutronException, self).__init__(self.message)
|
||||||
|
|
||||||
|
if six.PY2:
|
||||||
def __unicode__(self):
|
def __unicode__(self):
|
||||||
return unicode(self.msg)
|
return unicode(self.msg)
|
||||||
|
|
||||||
|
@ -268,7 +268,7 @@ class OwnerCheck(policy.Check):
|
|||||||
f)
|
f)
|
||||||
match = self.match % target
|
match = self.match % target
|
||||||
if self.kind in creds:
|
if self.kind in creds:
|
||||||
return match == unicode(creds[self.kind])
|
return match == six.text_type(creds[self.kind])
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
|
||||||
|
@ -929,7 +929,9 @@ class JSONV2TestCase(APIv2TestBase, testlib_api.WebTestCase):
|
|||||||
return_value.update(initial_input['port'])
|
return_value.update(initial_input['port'])
|
||||||
|
|
||||||
instance = self.plugin.return_value
|
instance = self.plugin.return_value
|
||||||
instance.get_network.return_value = {'tenant_id': unicode(tenant_id)}
|
instance.get_network.return_value = {
|
||||||
|
'tenant_id': six.text_type(tenant_id)
|
||||||
|
}
|
||||||
instance.get_ports_count.return_value = 1
|
instance.get_ports_count.return_value = 1
|
||||||
instance.create_port.return_value = return_value
|
instance.create_port.return_value = return_value
|
||||||
res = self.api.post(_get_path('ports', fmt=self.fmt),
|
res = self.api.post(_get_path('ports', fmt=self.fmt),
|
||||||
|
@ -422,7 +422,7 @@ class JSONDictSerializer(DictSerializer):
|
|||||||
|
|
||||||
def default(self, data):
|
def default(self, data):
|
||||||
def sanitizer(obj):
|
def sanitizer(obj):
|
||||||
return unicode(obj)
|
return six.text_type(obj)
|
||||||
return jsonutils.dumps(data, default=sanitizer)
|
return jsonutils.dumps(data, default=sanitizer)
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user