Merge "[Part3] Remove six"

This commit is contained in:
Zuul 2021-09-09 01:54:51 +00:00 committed by Gerrit Code Review
commit c7d9976e15
13 changed files with 44 additions and 57 deletions

View File

@ -16,7 +16,6 @@ import falcon
import jsonschema
from oslo_log import log as logging
import six
from zaqar.i18n import _
from zaqar.transport import utils
@ -212,7 +211,7 @@ def validate(validator, document):
validator.validate(document)
except jsonschema.ValidationError as ex:
raise errors.HTTPBadRequestBody(
'{0}: {1}'.format(ex.args, six.text_type(ex))
'{0}: {1}'.format(ex.args, str(ex))
)

View File

@ -15,7 +15,6 @@
import falcon
from oslo_log import log as logging
import six
from zaqar.common import decorators
from zaqar.i18n import _
@ -68,7 +67,7 @@ class CollectionResource(Resource):
except validation.ValidationFailed as ex:
LOG.debug(ex)
raise wsgi_errors.HTTPBadRequestAPI(six.text_type(ex))
raise wsgi_errors.HTTPBadRequestAPI(str(ex))
except Exception:
description = _(u'Claim could not be created.')
@ -110,7 +109,7 @@ class ItemResource(Resource):
except storage_errors.DoesNotExist as ex:
LOG.debug(ex)
raise wsgi_errors.HTTPNotFound(six.text_type(ex))
raise wsgi_errors.HTTPNotFound(str(ex))
except Exception:
description = _(u'Claim could not be queried.')
LOG.exception(description)
@ -147,11 +146,11 @@ class ItemResource(Resource):
except validation.ValidationFailed as ex:
LOG.debug(ex)
raise wsgi_errors.HTTPBadRequestAPI(six.text_type(ex))
raise wsgi_errors.HTTPBadRequestAPI(str(ex))
except storage_errors.DoesNotExist as ex:
LOG.debug(ex)
raise wsgi_errors.HTTPNotFound(six.text_type(ex))
raise wsgi_errors.HTTPNotFound(str(ex))
except Exception:
description = _(u'Claim could not be updated.')

View File

@ -15,7 +15,6 @@
import falcon
from oslo_log import log as logging
import six
from zaqar.common import decorators
from zaqar.common.transport.wsgi import helpers as wsgi_helpers
@ -55,7 +54,7 @@ class CollectionResource(object):
except validation.ValidationFailed as ex:
LOG.debug(ex)
raise wsgi_errors.HTTPBadRequestAPI(six.text_type(ex))
raise wsgi_errors.HTTPBadRequestAPI(str(ex))
except Exception:
description = _(u'Message could not be retrieved.')
@ -94,11 +93,11 @@ class CollectionResource(object):
except validation.ValidationFailed as ex:
LOG.debug(ex)
raise wsgi_errors.HTTPBadRequestAPI(six.text_type(ex))
raise wsgi_errors.HTTPBadRequestAPI(str(ex))
except storage_errors.DoesNotExist as ex:
LOG.debug(ex)
raise wsgi_errors.HTTPNotFound(six.text_type(ex))
raise wsgi_errors.HTTPNotFound(str(ex))
except Exception:
description = _(u'Messages could not be listed.')
@ -137,7 +136,7 @@ class CollectionResource(object):
self._validate.message_length(req.content_length)
except validation.ValidationFailed as ex:
LOG.debug(ex)
raise wsgi_errors.HTTPBadRequestAPI(six.text_type(ex))
raise wsgi_errors.HTTPBadRequestAPI(str(ex))
# Deserialize and validate the request body
document = wsgi_utils.deserialize(req.stream, req.content_length)
@ -155,11 +154,11 @@ class CollectionResource(object):
except validation.ValidationFailed as ex:
LOG.debug(ex)
raise wsgi_errors.HTTPBadRequestAPI(six.text_type(ex))
raise wsgi_errors.HTTPBadRequestAPI(str(ex))
except storage_errors.DoesNotExist as ex:
LOG.debug(ex)
raise wsgi_errors.HTTPNotFound(six.text_type(ex))
raise wsgi_errors.HTTPNotFound(str(ex))
except storage_errors.MessageConflict:
description = _(u'No messages could be enqueued.')
@ -220,7 +219,7 @@ class CollectionResource(object):
except validation.ValidationFailed as ex:
LOG.debug(ex)
raise wsgi_errors.HTTPBadRequestAPI(six.text_type(ex))
raise wsgi_errors.HTTPBadRequestAPI(str(ex))
except Exception:
description = _(u'Messages could not be deleted.')
@ -247,7 +246,7 @@ class ItemResource(object):
except storage_errors.DoesNotExist as ex:
LOG.debug(ex)
raise wsgi_errors.HTTPNotFound(six.text_type(ex))
raise wsgi_errors.HTTPNotFound(str(ex))
except Exception:
description = _(u'Message could not be retrieved.')

View File

@ -15,7 +15,6 @@
import falcon
from oslo_log import log as logging
import six
from zaqar.common import decorators
from zaqar.i18n import _
@ -45,7 +44,7 @@ class Resource(object):
except storage_errors.DoesNotExist as ex:
LOG.debug(ex)
raise wsgi_errors.HTTPNotFound(six.text_type(ex))
raise wsgi_errors.HTTPNotFound(str(ex))
except Exception:
description = _(u'Queue metadata could not be retrieved.')
@ -73,7 +72,7 @@ class Resource(object):
raise validation.ValidationFailed(description)
except validation.ValidationFailed as ex:
LOG.debug(ex)
raise wsgi_errors.HTTPBadRequestAPI(six.text_type(ex))
raise wsgi_errors.HTTPBadRequestAPI(str(ex))
try:
self._queue_ctrl.set_metadata(queue_name,
@ -82,10 +81,10 @@ class Resource(object):
except validation.ValidationFailed as ex:
LOG.debug(ex)
raise wsgi_errors.HTTPBadRequestAPI(six.text_type(ex))
raise wsgi_errors.HTTPBadRequestAPI(str(ex))
except storage_errors.QueueDoesNotExist as ex:
raise wsgi_errors.HTTPNotFound(six.text_type(ex))
raise wsgi_errors.HTTPNotFound(str(ex))
except Exception:
description = _(u'Metadata could not be updated.')

View File

@ -38,7 +38,6 @@ registered, there is an optional field::
import falcon
import jsonschema
from oslo_log import log
import six
from zaqar.common.api.schemas import pools as schema
from zaqar.common import utils as common_utils
@ -144,7 +143,7 @@ class Resource(object):
except errors.PoolDoesNotExist as ex:
LOG.debug(ex)
raise wsgi_errors.HTTPNotFound(six.text_type(ex))
raise wsgi_errors.HTTPNotFound(str(ex))
data['href'] = request.path
@ -180,7 +179,7 @@ class Resource(object):
response.location = request.path
except errors.PoolAlreadyExists as e:
LOG.exception('Pool "%s" already exists', pool)
raise wsgi_errors.HTTPConflict(six.text_type(e))
raise wsgi_errors.HTTPConflict(str(e))
def on_delete(self, request, response, project_id, pool):
"""Deregisters a pool.
@ -232,4 +231,4 @@ class Resource(object):
self._ctrl.update(pool, **fields)
except errors.PoolDoesNotExist as ex:
LOG.exception('Pool "%s" does not exist', pool)
raise wsgi_errors.HTTPNotFound(six.text_type(ex))
raise wsgi_errors.HTTPNotFound(str(ex))

View File

@ -15,7 +15,6 @@
import falcon
from oslo_log import log as logging
import six
from zaqar.common import decorators
from zaqar.i18n import _
@ -101,7 +100,7 @@ class CollectionResource(object):
except validation.ValidationFailed as ex:
LOG.debug(ex)
raise wsgi_errors.HTTPBadRequestAPI(six.text_type(ex))
raise wsgi_errors.HTTPBadRequestAPI(str(ex))
except Exception:
description = _(u'Queues could not be listed.')

View File

@ -14,7 +14,6 @@
# limitations under the License.
from oslo_log import log as logging
import six
from zaqar.i18n import _
from zaqar.storage import errors as storage_errors
@ -65,7 +64,7 @@ class Resource(object):
resp.body = utils.to_json(resp_dict)
except storage_errors.DoesNotExist as ex:
LOG.debug(ex)
raise wsgi_errors.HTTPNotFound(six.text_type(ex))
raise wsgi_errors.HTTPNotFound(str(ex))
except Exception:
description = _(u'Queue stats could not be read.')

View File

@ -15,7 +15,6 @@
import falcon
from oslo_log import log as logging
import six
from zaqar.common import decorators
from zaqar.i18n import _
@ -88,7 +87,7 @@ class CollectionResource(object):
except validation.ValidationFailed as ex:
LOG.debug(ex)
raise wsgi_errors.HTTPBadRequestAPI(six.text_type(ex))
raise wsgi_errors.HTTPBadRequestAPI(str(ex))
except Exception:
description = _(u'Claim could not be created.')
@ -137,7 +136,7 @@ class ItemResource(object):
except storage_errors.DoesNotExist as ex:
LOG.debug(ex)
raise wsgi_errors.HTTPNotFound(six.text_type(ex))
raise wsgi_errors.HTTPNotFound(str(ex))
except Exception:
description = _(u'Claim could not be queried.')
LOG.exception(description)
@ -174,11 +173,11 @@ class ItemResource(object):
except validation.ValidationFailed as ex:
LOG.debug(ex)
raise wsgi_errors.HTTPBadRequestAPI(six.text_type(ex))
raise wsgi_errors.HTTPBadRequestAPI(str(ex))
except storage_errors.DoesNotExist as ex:
LOG.debug(ex)
raise wsgi_errors.HTTPNotFound(six.text_type(ex))
raise wsgi_errors.HTTPNotFound(str(ex))
except Exception:
description = _(u'Claim could not be updated.')

View File

@ -16,7 +16,6 @@
import falcon
import jsonschema
from oslo_log import log
import six
from zaqar.common.api.schemas.v1_1 import flavors as schema
from zaqar.common import utils as common_utils
@ -122,7 +121,7 @@ class Resource(object):
detailed=detailed)
except errors.FlavorDoesNotExist as ex:
LOG.debug(ex)
raise wsgi_errors.HTTPNotFound(six.text_type(ex))
raise wsgi_errors.HTTPNotFound(str(ex))
data['href'] = request.path
@ -200,4 +199,4 @@ class Resource(object):
self._ctrl.update(flavor, project=project_id, **fields)
except errors.FlavorDoesNotExist as ex:
LOG.exception('Flavor "%s" does not exist', flavor)
raise wsgi_errors.HTTPNotFound(six.text_type(ex))
raise wsgi_errors.HTTPNotFound(str(ex))

View File

@ -15,7 +15,6 @@
import falcon
from oslo_log import log as logging
import six
from zaqar.common import decorators
from zaqar.common.transport.wsgi import helpers as wsgi_helpers
@ -68,7 +67,7 @@ class CollectionResource(object):
except validation.ValidationFailed as ex:
LOG.debug(ex)
raise wsgi_errors.HTTPBadRequestAPI(six.text_type(ex))
raise wsgi_errors.HTTPBadRequestAPI(str(ex))
except Exception:
description = _(u'Message could not be retrieved.')
@ -110,7 +109,7 @@ class CollectionResource(object):
except validation.ValidationFailed as ex:
LOG.debug(ex)
raise wsgi_errors.HTTPBadRequestAPI(six.text_type(ex))
raise wsgi_errors.HTTPBadRequestAPI(str(ex))
except storage_errors.QueueDoesNotExist as ex:
LOG.debug(ex)
@ -159,7 +158,7 @@ class CollectionResource(object):
self._validate.message_length(req.content_length)
except validation.ValidationFailed as ex:
LOG.debug(ex)
raise wsgi_errors.HTTPBadRequestAPI(six.text_type(ex))
raise wsgi_errors.HTTPBadRequestAPI(str(ex))
# Deserialize and validate the incoming messages
document = wsgi_utils.deserialize(req.stream, req.content_length)
@ -186,11 +185,11 @@ class CollectionResource(object):
except validation.ValidationFailed as ex:
LOG.debug(ex)
raise wsgi_errors.HTTPBadRequestAPI(six.text_type(ex))
raise wsgi_errors.HTTPBadRequestAPI(str(ex))
except storage_errors.DoesNotExist as ex:
LOG.debug(ex)
raise wsgi_errors.HTTPNotFound(six.text_type(ex))
raise wsgi_errors.HTTPNotFound(str(ex))
except storage_errors.MessageConflict:
description = _(u'No messages could be enqueued.')
@ -245,7 +244,7 @@ class CollectionResource(object):
except validation.ValidationFailed as ex:
LOG.debug(ex)
raise wsgi_errors.HTTPBadRequestAPI(six.text_type(ex))
raise wsgi_errors.HTTPBadRequestAPI(str(ex))
if ids:
resp.status = self._delete_messages_by_id(queue_name, ids,
@ -312,7 +311,7 @@ class ItemResource(object):
except storage_errors.DoesNotExist as ex:
LOG.debug(ex)
raise wsgi_errors.HTTPNotFound(six.text_type(ex))
raise wsgi_errors.HTTPNotFound(str(ex))
except Exception:
description = _(u'Message could not be retrieved.')

View File

@ -39,7 +39,6 @@ registered, there is an optional field:
import falcon
import jsonschema
from oslo_log import log
import six
from zaqar.common.api.schemas import pools as schema
from zaqar.common import utils as common_utils
@ -148,7 +147,7 @@ class Resource(object):
except errors.PoolDoesNotExist as ex:
LOG.debug(ex)
raise wsgi_errors.HTTPNotFound(six.text_type(ex))
raise wsgi_errors.HTTPNotFound(str(ex))
data['href'] = request.path
@ -184,10 +183,10 @@ class Resource(object):
except errors.PoolCapabilitiesMismatch as e:
title = _(u'Unable to create pool')
LOG.exception(title)
raise falcon.HTTPBadRequest(title, six.text_type(e))
raise falcon.HTTPBadRequest(title, str(e))
except errors.PoolAlreadyExists as e:
LOG.exception('Pool "%s" already exists', pool)
raise wsgi_errors.HTTPConflict(six.text_type(e))
raise wsgi_errors.HTTPConflict(str(e))
def on_delete(self, request, response, project_id, pool):
"""Deregisters a pool.
@ -249,4 +248,4 @@ class Resource(object):
self._ctrl.update(pool, **fields)
except errors.PoolDoesNotExist as ex:
LOG.exception('Pool "%s" does not exist', pool)
raise wsgi_errors.HTTPNotFound(six.text_type(ex))
raise wsgi_errors.HTTPNotFound(str(ex))

View File

@ -15,7 +15,6 @@
import falcon
from oslo_log import log as logging
import six
from zaqar.common import decorators
from zaqar.i18n import _
@ -46,7 +45,7 @@ class ItemResource(object):
except storage_errors.DoesNotExist as ex:
LOG.debug(ex)
raise wsgi_errors.HTTPNotFound(six.text_type(ex))
raise wsgi_errors.HTTPNotFound(str(ex))
except Exception:
description = _(u'Queue metadata could not be retrieved.')
@ -73,7 +72,7 @@ class ItemResource(object):
self._validate.queue_metadata_putting(metadata)
except validation.ValidationFailed as ex:
LOG.debug(ex)
raise wsgi_errors.HTTPBadRequestAPI(six.text_type(ex))
raise wsgi_errors.HTTPBadRequestAPI(str(ex))
try:
created = self._queue_controller.create(queue_name,
@ -82,7 +81,7 @@ class ItemResource(object):
except storage_errors.FlavorDoesNotExist as ex:
LOG.exception('"%s" does not exist', queue_name)
raise wsgi_errors.HTTPBadRequestAPI(six.text_type(ex))
raise wsgi_errors.HTTPBadRequestAPI(str(ex))
except Exception:
description = _(u'Queue could not be created.')
@ -132,7 +131,7 @@ class CollectionResource(object):
except validation.ValidationFailed as ex:
LOG.debug(ex)
raise wsgi_errors.HTTPBadRequestAPI(six.text_type(ex))
raise wsgi_errors.HTTPBadRequestAPI(str(ex))
except Exception:
description = _(u'Queues could not be listed.')

View File

@ -14,7 +14,6 @@
# limitations under the License.
from oslo_log import log as logging
import six
from zaqar.i18n import _
from zaqar.storage import errors as storage_errors
@ -66,7 +65,7 @@ class Resource(object):
except storage_errors.DoesNotExist as ex:
LOG.debug(ex)
raise wsgi_errors.HTTPNotFound(six.text_type(ex))
raise wsgi_errors.HTTPNotFound(str(ex))
except Exception:
description = _(u'Queue stats could not be read.')