Remove i18n stub
This removes the translation functions from the codebase and drops the i18n integration stub. Change-Id: I4cd21d25f768e6915f813a784b89eb66f6fe006f
This commit is contained in:
parent
ebb48db1c8
commit
7201269804
@ -17,7 +17,6 @@
|
|||||||
import functools
|
import functools
|
||||||
|
|
||||||
from keystoneauth import _utils as utils
|
from keystoneauth import _utils as utils
|
||||||
from keystoneauth.i18n import _
|
|
||||||
from keystoneauth import service_catalog
|
from keystoneauth import service_catalog
|
||||||
|
|
||||||
|
|
||||||
@ -38,7 +37,7 @@ def create(resp=None, body=None, auth_token=None):
|
|||||||
elif 'access' in body:
|
elif 'access' in body:
|
||||||
return AccessInfoV2(body, auth_token)
|
return AccessInfoV2(body, auth_token)
|
||||||
|
|
||||||
raise ValueError(_('Unrecognized auth response'))
|
raise ValueError('Unrecognized auth response')
|
||||||
|
|
||||||
|
|
||||||
def missingproperty(f):
|
def missingproperty(f):
|
||||||
|
@ -20,7 +20,6 @@ from keystoneauth import _utils as utils
|
|||||||
from keystoneauth.auth import base
|
from keystoneauth.auth import base
|
||||||
from keystoneauth import discover
|
from keystoneauth import discover
|
||||||
from keystoneauth import exceptions
|
from keystoneauth import exceptions
|
||||||
from keystoneauth.i18n import _LW
|
|
||||||
|
|
||||||
LOG = logging.getLogger(__name__)
|
LOG = logging.getLogger(__name__)
|
||||||
|
|
||||||
@ -205,9 +204,9 @@ class BaseIdentityPlugin(base.BaseAuthPlugin):
|
|||||||
return self.auth_url
|
return self.auth_url
|
||||||
|
|
||||||
if not service_type:
|
if not service_type:
|
||||||
LOG.warn(_LW('Plugin cannot return an endpoint without knowing '
|
LOG.warn('Plugin cannot return an endpoint without knowing '
|
||||||
'the service type that is required. Add service_type '
|
'the service type that is required. Add service_type '
|
||||||
'to endpoint filtering data.'))
|
'to endpoint filtering data.')
|
||||||
return None
|
return None
|
||||||
|
|
||||||
if not interface:
|
if not interface:
|
||||||
@ -240,8 +239,8 @@ class BaseIdentityPlugin(base.BaseAuthPlugin):
|
|||||||
# NOTE(jamielennox): Again if we can't contact the server we fall
|
# NOTE(jamielennox): Again if we can't contact the server we fall
|
||||||
# back to just returning the URL from the catalog. This may not be
|
# back to just returning the URL from the catalog. This may not be
|
||||||
# the best default but we need it for now.
|
# the best default but we need it for now.
|
||||||
LOG.warn(_LW('Failed to contact the endpoint at %s for discovery. '
|
LOG.warn('Failed to contact the endpoint at %s for discovery. '
|
||||||
'Fallback to using that endpoint as the base url.'),
|
'Fallback to using that endpoint as the base url.',
|
||||||
url)
|
url)
|
||||||
else:
|
else:
|
||||||
url = disc.url_for(version)
|
url = disc.url_for(version)
|
||||||
|
@ -20,7 +20,6 @@ import six.moves.urllib.parse as urlparse
|
|||||||
from keystoneauth.auth.identity import base
|
from keystoneauth.auth.identity import base
|
||||||
from keystoneauth import discover
|
from keystoneauth import discover
|
||||||
from keystoneauth import exceptions
|
from keystoneauth import exceptions
|
||||||
from keystoneauth.i18n import _, _LW
|
|
||||||
|
|
||||||
|
|
||||||
LOG = logging.getLogger(__name__)
|
LOG = logging.getLogger(__name__)
|
||||||
@ -130,9 +129,9 @@ class BaseGenericPlugin(base.BaseIdentityPlugin):
|
|||||||
except (exceptions.DiscoveryFailure,
|
except (exceptions.DiscoveryFailure,
|
||||||
exceptions.HttpError,
|
exceptions.HttpError,
|
||||||
exceptions.ConnectionError):
|
exceptions.ConnectionError):
|
||||||
LOG.warn(_LW('Discovering versions from the identity service '
|
LOG.warn('Discovering versions from the identity service '
|
||||||
'failed when creating the password plugin. '
|
'failed when creating the password plugin. '
|
||||||
'Attempting to determine version from URL.'))
|
'Attempting to determine version from URL.')
|
||||||
|
|
||||||
url_parts = urlparse.urlparse(self.auth_url)
|
url_parts = urlparse.urlparse(self.auth_url)
|
||||||
path = url_parts.path.lower()
|
path = url_parts.path.lower()
|
||||||
@ -166,7 +165,7 @@ class BaseGenericPlugin(base.BaseIdentityPlugin):
|
|||||||
return plugin
|
return plugin
|
||||||
|
|
||||||
# so there were no URLs that i could use for auth of any version.
|
# so there were no URLs that i could use for auth of any version.
|
||||||
msg = _('Could not determine a suitable URL for the plugin')
|
msg = 'Could not determine a suitable URL for the plugin'
|
||||||
raise exceptions.DiscoveryFailure(msg)
|
raise exceptions.DiscoveryFailure(msg)
|
||||||
|
|
||||||
def get_auth_ref(self, session, **kwargs):
|
def get_auth_ref(self, session, **kwargs):
|
||||||
|
@ -20,7 +20,6 @@ from keystoneauth import _utils as utils
|
|||||||
from keystoneauth import access
|
from keystoneauth import access
|
||||||
from keystoneauth.auth.identity import base
|
from keystoneauth.auth.identity import base
|
||||||
from keystoneauth import exceptions
|
from keystoneauth import exceptions
|
||||||
from keystoneauth.i18n import _
|
|
||||||
|
|
||||||
_logger = logging.getLogger(__name__)
|
_logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
@ -138,7 +137,7 @@ class Auth(BaseAuth):
|
|||||||
|
|
||||||
if not ident:
|
if not ident:
|
||||||
raise exceptions.AuthorizationFailure(
|
raise exceptions.AuthorizationFailure(
|
||||||
_('Authentication method required (e.g. password)'))
|
'Authentication method required (e.g. password)')
|
||||||
|
|
||||||
mutual_exclusion = [bool(self.domain_id or self.domain_name),
|
mutual_exclusion = [bool(self.domain_id or self.domain_name),
|
||||||
bool(self.project_id or self.project_name),
|
bool(self.project_id or self.project_name),
|
||||||
@ -147,8 +146,8 @@ class Auth(BaseAuth):
|
|||||||
|
|
||||||
if sum(mutual_exclusion) > 1:
|
if sum(mutual_exclusion) > 1:
|
||||||
raise exceptions.AuthorizationFailure(
|
raise exceptions.AuthorizationFailure(
|
||||||
_('Authentication cannot be scoped to multiple targets. Pick '
|
'Authentication cannot be scoped to multiple targets. Pick '
|
||||||
'one of: project, domain, trust or unscoped'))
|
'one of: project, domain, trust or unscoped')
|
||||||
|
|
||||||
if self.domain_id:
|
if self.domain_id:
|
||||||
body['auth']['scope'] = {'domain': {'id': self.domain_id}}
|
body['auth']['scope'] = {'domain': {'id': self.domain_id}}
|
||||||
@ -211,7 +210,7 @@ class AuthMethod(object):
|
|||||||
setattr(self, param, kwargs.pop(param, None))
|
setattr(self, param, kwargs.pop(param, None))
|
||||||
|
|
||||||
if kwargs:
|
if kwargs:
|
||||||
msg = _("Unexpected Attributes: %s") % ", ".join(kwargs.keys())
|
msg = "Unexpected Attributes: %s" % ", ".join(kwargs.keys())
|
||||||
raise AttributeError(msg)
|
raise AttributeError(msg)
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
|
@ -26,7 +26,6 @@ import re
|
|||||||
|
|
||||||
from keystoneauth import _utils as utils
|
from keystoneauth import _utils as utils
|
||||||
from keystoneauth import exceptions
|
from keystoneauth import exceptions
|
||||||
from keystoneauth.i18n import _, _LI, _LW
|
|
||||||
|
|
||||||
|
|
||||||
_LOGGER = logging.getLogger(__name__)
|
_LOGGER = logging.getLogger(__name__)
|
||||||
@ -66,7 +65,7 @@ def get_version_data(session, url, authenticated=None):
|
|||||||
pass
|
pass
|
||||||
|
|
||||||
err_text = resp.text[:50] + '...' if len(resp.text) > 50 else resp.text
|
err_text = resp.text[:50] + '...' if len(resp.text) > 50 else resp.text
|
||||||
msg = _('Invalid Response - Bad version data returned: %s') % err_text
|
msg = 'Invalid Response - Bad version data returned: %s' % err_text
|
||||||
raise exceptions.DiscoveryFailure(msg)
|
raise exceptions.DiscoveryFailure(msg)
|
||||||
|
|
||||||
|
|
||||||
@ -100,7 +99,7 @@ def normalize_version_number(version):
|
|||||||
except Exception:
|
except Exception:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
raise TypeError(_('Invalid version specified: %s') % version)
|
raise TypeError('Invalid version specified: %s' % version)
|
||||||
|
|
||||||
|
|
||||||
def version_match(required, candidate):
|
def version_match(required, candidate):
|
||||||
@ -162,8 +161,8 @@ class Discover(object):
|
|||||||
try:
|
try:
|
||||||
status = v['status']
|
status = v['status']
|
||||||
except KeyError:
|
except KeyError:
|
||||||
_LOGGER.warning(_LW('Skipping over invalid version data. '
|
_LOGGER.warning('Skipping over invalid version data. '
|
||||||
'No stability status in version.'))
|
'No stability status in version.')
|
||||||
continue
|
continue
|
||||||
|
|
||||||
status = status.lower()
|
status = status.lower()
|
||||||
@ -202,14 +201,13 @@ class Discover(object):
|
|||||||
try:
|
try:
|
||||||
version_str = v['id']
|
version_str = v['id']
|
||||||
except KeyError:
|
except KeyError:
|
||||||
_LOGGER.info(_LI('Skipping invalid version data. Missing ID.'))
|
_LOGGER.info('Skipping invalid version data. Missing ID.')
|
||||||
continue
|
continue
|
||||||
|
|
||||||
try:
|
try:
|
||||||
links = v['links']
|
links = v['links']
|
||||||
except KeyError:
|
except KeyError:
|
||||||
_LOGGER.info(
|
_LOGGER.info('Skipping invalid version data. Missing links')
|
||||||
_LI('Skipping invalid version data. Missing links'))
|
|
||||||
continue
|
continue
|
||||||
|
|
||||||
version_number = normalize_version_number(version_str)
|
version_number = normalize_version_number(version_str)
|
||||||
@ -219,15 +217,15 @@ class Discover(object):
|
|||||||
rel = link['rel']
|
rel = link['rel']
|
||||||
url = link['href']
|
url = link['href']
|
||||||
except (KeyError, TypeError):
|
except (KeyError, TypeError):
|
||||||
_LOGGER.info(_LI('Skipping invalid version link. '
|
_LOGGER.info('Skipping invalid version link. '
|
||||||
'Missing link URL or relationship.'))
|
'Missing link URL or relationship.')
|
||||||
continue
|
continue
|
||||||
|
|
||||||
if rel.lower() == 'self':
|
if rel.lower() == 'self':
|
||||||
break
|
break
|
||||||
else:
|
else:
|
||||||
_LOGGER.info(_LI('Skipping invalid version data. '
|
_LOGGER.info('Skipping invalid version data. '
|
||||||
'Missing link to endpoint.'))
|
'Missing link to endpoint.')
|
||||||
continue
|
continue
|
||||||
|
|
||||||
versions.append({'version': version_number,
|
versions.append({'version': version_number,
|
||||||
|
@ -11,7 +11,6 @@
|
|||||||
# under the License.
|
# under the License.
|
||||||
|
|
||||||
from keystoneauth.exceptions import base
|
from keystoneauth.exceptions import base
|
||||||
from keystoneauth.i18n import _
|
|
||||||
|
|
||||||
|
|
||||||
class AuthPluginException(base.ClientException):
|
class AuthPluginException(base.ClientException):
|
||||||
@ -35,5 +34,5 @@ class NoMatchingPlugin(AuthPluginException):
|
|||||||
|
|
||||||
def __init__(self, name):
|
def __init__(self, name):
|
||||||
self.name = name
|
self.name = name
|
||||||
msg = _('The plugin %s could not be found') % name
|
msg = 'The plugin %s could not be found' % name
|
||||||
super(NoMatchingPlugin, self).__init__(msg)
|
super(NoMatchingPlugin, self).__init__(msg)
|
||||||
|
@ -26,7 +26,6 @@ import sys
|
|||||||
import six
|
import six
|
||||||
|
|
||||||
from keystoneauth.exceptions import base
|
from keystoneauth.exceptions import base
|
||||||
from keystoneauth.i18n import _
|
|
||||||
|
|
||||||
|
|
||||||
__all__ = ['HttpError',
|
__all__ = ['HttpError',
|
||||||
@ -67,7 +66,7 @@ class HttpError(base.ClientException):
|
|||||||
"""The base exception class for all HTTP exceptions.
|
"""The base exception class for all HTTP exceptions.
|
||||||
"""
|
"""
|
||||||
http_status = 0
|
http_status = 0
|
||||||
message = _("HTTP Error")
|
message = "HTTP Error"
|
||||||
|
|
||||||
def __init__(self, message=None, details=None,
|
def __init__(self, message=None, details=None,
|
||||||
response=None, request_id=None,
|
response=None, request_id=None,
|
||||||
@ -90,7 +89,7 @@ class HTTPClientError(HttpError):
|
|||||||
|
|
||||||
Exception for cases in which the client seems to have erred.
|
Exception for cases in which the client seems to have erred.
|
||||||
"""
|
"""
|
||||||
message = _("HTTP Client Error")
|
message = "HTTP Client Error"
|
||||||
|
|
||||||
|
|
||||||
class HttpServerError(HttpError):
|
class HttpServerError(HttpError):
|
||||||
@ -99,7 +98,7 @@ class HttpServerError(HttpError):
|
|||||||
Exception for cases in which the server is aware that it has
|
Exception for cases in which the server is aware that it has
|
||||||
erred or is incapable of performing the request.
|
erred or is incapable of performing the request.
|
||||||
"""
|
"""
|
||||||
message = _("HTTP Server Error")
|
message = "HTTP Server Error"
|
||||||
|
|
||||||
|
|
||||||
class BadRequest(HTTPClientError):
|
class BadRequest(HTTPClientError):
|
||||||
@ -108,7 +107,7 @@ class BadRequest(HTTPClientError):
|
|||||||
The request cannot be fulfilled due to bad syntax.
|
The request cannot be fulfilled due to bad syntax.
|
||||||
"""
|
"""
|
||||||
http_status = 400
|
http_status = 400
|
||||||
message = _("Bad Request")
|
message = "Bad Request"
|
||||||
|
|
||||||
|
|
||||||
class Unauthorized(HTTPClientError):
|
class Unauthorized(HTTPClientError):
|
||||||
@ -118,7 +117,7 @@ class Unauthorized(HTTPClientError):
|
|||||||
is required and has failed or has not yet been provided.
|
is required and has failed or has not yet been provided.
|
||||||
"""
|
"""
|
||||||
http_status = 401
|
http_status = 401
|
||||||
message = _("Unauthorized")
|
message = "Unauthorized"
|
||||||
|
|
||||||
|
|
||||||
class PaymentRequired(HTTPClientError):
|
class PaymentRequired(HTTPClientError):
|
||||||
@ -127,7 +126,7 @@ class PaymentRequired(HTTPClientError):
|
|||||||
Reserved for future use.
|
Reserved for future use.
|
||||||
"""
|
"""
|
||||||
http_status = 402
|
http_status = 402
|
||||||
message = _("Payment Required")
|
message = "Payment Required"
|
||||||
|
|
||||||
|
|
||||||
class Forbidden(HTTPClientError):
|
class Forbidden(HTTPClientError):
|
||||||
@ -137,7 +136,7 @@ class Forbidden(HTTPClientError):
|
|||||||
to it.
|
to it.
|
||||||
"""
|
"""
|
||||||
http_status = 403
|
http_status = 403
|
||||||
message = _("Forbidden")
|
message = "Forbidden"
|
||||||
|
|
||||||
|
|
||||||
class NotFound(HTTPClientError):
|
class NotFound(HTTPClientError):
|
||||||
@ -147,7 +146,7 @@ class NotFound(HTTPClientError):
|
|||||||
in the future.
|
in the future.
|
||||||
"""
|
"""
|
||||||
http_status = 404
|
http_status = 404
|
||||||
message = _("Not Found")
|
message = "Not Found"
|
||||||
|
|
||||||
|
|
||||||
class MethodNotAllowed(HTTPClientError):
|
class MethodNotAllowed(HTTPClientError):
|
||||||
@ -157,7 +156,7 @@ class MethodNotAllowed(HTTPClientError):
|
|||||||
by that resource.
|
by that resource.
|
||||||
"""
|
"""
|
||||||
http_status = 405
|
http_status = 405
|
||||||
message = _("Method Not Allowed")
|
message = "Method Not Allowed"
|
||||||
|
|
||||||
|
|
||||||
class NotAcceptable(HTTPClientError):
|
class NotAcceptable(HTTPClientError):
|
||||||
@ -167,7 +166,7 @@ class NotAcceptable(HTTPClientError):
|
|||||||
acceptable according to the Accept headers sent in the request.
|
acceptable according to the Accept headers sent in the request.
|
||||||
"""
|
"""
|
||||||
http_status = 406
|
http_status = 406
|
||||||
message = _("Not Acceptable")
|
message = "Not Acceptable"
|
||||||
|
|
||||||
|
|
||||||
class ProxyAuthenticationRequired(HTTPClientError):
|
class ProxyAuthenticationRequired(HTTPClientError):
|
||||||
@ -176,7 +175,7 @@ class ProxyAuthenticationRequired(HTTPClientError):
|
|||||||
The client must first authenticate itself with the proxy.
|
The client must first authenticate itself with the proxy.
|
||||||
"""
|
"""
|
||||||
http_status = 407
|
http_status = 407
|
||||||
message = _("Proxy Authentication Required")
|
message = "Proxy Authentication Required"
|
||||||
|
|
||||||
|
|
||||||
class RequestTimeout(HTTPClientError):
|
class RequestTimeout(HTTPClientError):
|
||||||
@ -185,7 +184,7 @@ class RequestTimeout(HTTPClientError):
|
|||||||
The server timed out waiting for the request.
|
The server timed out waiting for the request.
|
||||||
"""
|
"""
|
||||||
http_status = 408
|
http_status = 408
|
||||||
message = _("Request Timeout")
|
message = "Request Timeout"
|
||||||
|
|
||||||
|
|
||||||
class Conflict(HTTPClientError):
|
class Conflict(HTTPClientError):
|
||||||
@ -195,7 +194,7 @@ class Conflict(HTTPClientError):
|
|||||||
in the request, such as an edit conflict.
|
in the request, such as an edit conflict.
|
||||||
"""
|
"""
|
||||||
http_status = 409
|
http_status = 409
|
||||||
message = _("Conflict")
|
message = "Conflict"
|
||||||
|
|
||||||
|
|
||||||
class Gone(HTTPClientError):
|
class Gone(HTTPClientError):
|
||||||
@ -205,7 +204,7 @@ class Gone(HTTPClientError):
|
|||||||
not be available again.
|
not be available again.
|
||||||
"""
|
"""
|
||||||
http_status = 410
|
http_status = 410
|
||||||
message = _("Gone")
|
message = "Gone"
|
||||||
|
|
||||||
|
|
||||||
class LengthRequired(HTTPClientError):
|
class LengthRequired(HTTPClientError):
|
||||||
@ -215,7 +214,7 @@ class LengthRequired(HTTPClientError):
|
|||||||
required by the requested resource.
|
required by the requested resource.
|
||||||
"""
|
"""
|
||||||
http_status = 411
|
http_status = 411
|
||||||
message = _("Length Required")
|
message = "Length Required"
|
||||||
|
|
||||||
|
|
||||||
class PreconditionFailed(HTTPClientError):
|
class PreconditionFailed(HTTPClientError):
|
||||||
@ -225,7 +224,7 @@ class PreconditionFailed(HTTPClientError):
|
|||||||
put on the request.
|
put on the request.
|
||||||
"""
|
"""
|
||||||
http_status = 412
|
http_status = 412
|
||||||
message = _("Precondition Failed")
|
message = "Precondition Failed"
|
||||||
|
|
||||||
|
|
||||||
class RequestEntityTooLarge(HTTPClientError):
|
class RequestEntityTooLarge(HTTPClientError):
|
||||||
@ -234,7 +233,7 @@ class RequestEntityTooLarge(HTTPClientError):
|
|||||||
The request is larger than the server is willing or able to process.
|
The request is larger than the server is willing or able to process.
|
||||||
"""
|
"""
|
||||||
http_status = 413
|
http_status = 413
|
||||||
message = _("Request Entity Too Large")
|
message = "Request Entity Too Large"
|
||||||
|
|
||||||
def __init__(self, *args, **kwargs):
|
def __init__(self, *args, **kwargs):
|
||||||
try:
|
try:
|
||||||
@ -251,7 +250,7 @@ class RequestUriTooLong(HTTPClientError):
|
|||||||
The URI provided was too long for the server to process.
|
The URI provided was too long for the server to process.
|
||||||
"""
|
"""
|
||||||
http_status = 414
|
http_status = 414
|
||||||
message = _("Request-URI Too Long")
|
message = "Request-URI Too Long"
|
||||||
|
|
||||||
|
|
||||||
class UnsupportedMediaType(HTTPClientError):
|
class UnsupportedMediaType(HTTPClientError):
|
||||||
@ -261,7 +260,7 @@ class UnsupportedMediaType(HTTPClientError):
|
|||||||
not support.
|
not support.
|
||||||
"""
|
"""
|
||||||
http_status = 415
|
http_status = 415
|
||||||
message = _("Unsupported Media Type")
|
message = "Unsupported Media Type"
|
||||||
|
|
||||||
|
|
||||||
class RequestedRangeNotSatisfiable(HTTPClientError):
|
class RequestedRangeNotSatisfiable(HTTPClientError):
|
||||||
@ -271,7 +270,7 @@ class RequestedRangeNotSatisfiable(HTTPClientError):
|
|||||||
supply that portion.
|
supply that portion.
|
||||||
"""
|
"""
|
||||||
http_status = 416
|
http_status = 416
|
||||||
message = _("Requested Range Not Satisfiable")
|
message = "Requested Range Not Satisfiable"
|
||||||
|
|
||||||
|
|
||||||
class ExpectationFailed(HTTPClientError):
|
class ExpectationFailed(HTTPClientError):
|
||||||
@ -280,7 +279,7 @@ class ExpectationFailed(HTTPClientError):
|
|||||||
The server cannot meet the requirements of the Expect request-header field.
|
The server cannot meet the requirements of the Expect request-header field.
|
||||||
"""
|
"""
|
||||||
http_status = 417
|
http_status = 417
|
||||||
message = _("Expectation Failed")
|
message = "Expectation Failed"
|
||||||
|
|
||||||
|
|
||||||
class UnprocessableEntity(HTTPClientError):
|
class UnprocessableEntity(HTTPClientError):
|
||||||
@ -290,7 +289,7 @@ class UnprocessableEntity(HTTPClientError):
|
|||||||
errors.
|
errors.
|
||||||
"""
|
"""
|
||||||
http_status = 422
|
http_status = 422
|
||||||
message = _("Unprocessable Entity")
|
message = "Unprocessable Entity"
|
||||||
|
|
||||||
|
|
||||||
class InternalServerError(HttpServerError):
|
class InternalServerError(HttpServerError):
|
||||||
@ -299,7 +298,7 @@ class InternalServerError(HttpServerError):
|
|||||||
A generic error message, given when no more specific message is suitable.
|
A generic error message, given when no more specific message is suitable.
|
||||||
"""
|
"""
|
||||||
http_status = 500
|
http_status = 500
|
||||||
message = _("Internal Server Error")
|
message = "Internal Server Error"
|
||||||
|
|
||||||
|
|
||||||
# NotImplemented is a python keyword.
|
# NotImplemented is a python keyword.
|
||||||
@ -310,7 +309,7 @@ class HttpNotImplemented(HttpServerError):
|
|||||||
the ability to fulfill the request.
|
the ability to fulfill the request.
|
||||||
"""
|
"""
|
||||||
http_status = 501
|
http_status = 501
|
||||||
message = _("Not Implemented")
|
message = "Not Implemented"
|
||||||
|
|
||||||
|
|
||||||
class BadGateway(HttpServerError):
|
class BadGateway(HttpServerError):
|
||||||
@ -320,7 +319,7 @@ class BadGateway(HttpServerError):
|
|||||||
response from the upstream server.
|
response from the upstream server.
|
||||||
"""
|
"""
|
||||||
http_status = 502
|
http_status = 502
|
||||||
message = _("Bad Gateway")
|
message = "Bad Gateway"
|
||||||
|
|
||||||
|
|
||||||
class ServiceUnavailable(HttpServerError):
|
class ServiceUnavailable(HttpServerError):
|
||||||
@ -329,7 +328,7 @@ class ServiceUnavailable(HttpServerError):
|
|||||||
The server is currently unavailable.
|
The server is currently unavailable.
|
||||||
"""
|
"""
|
||||||
http_status = 503
|
http_status = 503
|
||||||
message = _("Service Unavailable")
|
message = "Service Unavailable"
|
||||||
|
|
||||||
|
|
||||||
class GatewayTimeout(HttpServerError):
|
class GatewayTimeout(HttpServerError):
|
||||||
@ -339,7 +338,7 @@ class GatewayTimeout(HttpServerError):
|
|||||||
response from the upstream server.
|
response from the upstream server.
|
||||||
"""
|
"""
|
||||||
http_status = 504
|
http_status = 504
|
||||||
message = _("Gateway Timeout")
|
message = "Gateway Timeout"
|
||||||
|
|
||||||
|
|
||||||
class HttpVersionNotSupported(HttpServerError):
|
class HttpVersionNotSupported(HttpServerError):
|
||||||
@ -348,7 +347,7 @@ class HttpVersionNotSupported(HttpServerError):
|
|||||||
The server does not support the HTTP protocol version used in the request.
|
The server does not support the HTTP protocol version used in the request.
|
||||||
"""
|
"""
|
||||||
http_status = 505
|
http_status = 505
|
||||||
message = _("HTTP Version Not Supported")
|
message = "HTTP Version Not Supported"
|
||||||
|
|
||||||
|
|
||||||
# _code_map contains all the classes that have http_status attribute.
|
# _code_map contains all the classes that have http_status attribute.
|
||||||
|
@ -1,28 +0,0 @@
|
|||||||
# Copyright 2014 IBM Corp.
|
|
||||||
#
|
|
||||||
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
|
||||||
# not use this file except in compliance with the License. You may obtain
|
|
||||||
# a copy of the License at
|
|
||||||
#
|
|
||||||
# http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
#
|
|
||||||
# Unless required by applicable law or agreed to in writing, software
|
|
||||||
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
|
||||||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
|
||||||
# License for the specific language governing permissions and limitations
|
|
||||||
# under the License.
|
|
||||||
|
|
||||||
"""oslo.i18n integration stub.
|
|
||||||
|
|
||||||
This module is a stub to allow dropping the use of oslo.i18n without
|
|
||||||
requiring a change to all of the various strings throughout keystoneauth.
|
|
||||||
"""
|
|
||||||
|
|
||||||
# TODO(morganfainberg): Eliminate the use of translation functions around
|
|
||||||
# each string in the keystoneauth library and then remove this file.
|
|
||||||
|
|
||||||
_ = lambda x: x
|
|
||||||
_LI = _
|
|
||||||
_LW = _
|
|
||||||
_LE = _
|
|
||||||
_LC = _
|
|
@ -22,7 +22,6 @@ import six
|
|||||||
|
|
||||||
from keystoneauth import _utils as utils
|
from keystoneauth import _utils as utils
|
||||||
from keystoneauth import exceptions
|
from keystoneauth import exceptions
|
||||||
from keystoneauth.i18n import _
|
|
||||||
|
|
||||||
|
|
||||||
@six.add_metaclass(abc.ABCMeta)
|
@six.add_metaclass(abc.ABCMeta)
|
||||||
@ -166,7 +165,7 @@ class ServiceCatalog(object):
|
|||||||
|
|
||||||
"""
|
"""
|
||||||
if not self._catalog:
|
if not self._catalog:
|
||||||
raise exceptions.EmptyCatalog(_('The service catalog is empty.'))
|
raise exceptions.EmptyCatalog('The service catalog is empty.')
|
||||||
|
|
||||||
urls = self.get_urls(service_type=service_type,
|
urls = self.get_urls(service_type=service_type,
|
||||||
endpoint_type=endpoint_type,
|
endpoint_type=endpoint_type,
|
||||||
@ -179,26 +178,26 @@ class ServiceCatalog(object):
|
|||||||
pass
|
pass
|
||||||
|
|
||||||
if service_name and region_name:
|
if service_name and region_name:
|
||||||
msg = (_('%(endpoint_type)s endpoint for %(service_type)s service '
|
msg = ('%(endpoint_type)s endpoint for %(service_type)s service '
|
||||||
'named %(service_name)s in %(region_name)s region not '
|
'named %(service_name)s in %(region_name)s region not '
|
||||||
'found') %
|
'found' %
|
||||||
{'endpoint_type': endpoint_type,
|
{'endpoint_type': endpoint_type,
|
||||||
'service_type': service_type, 'service_name': service_name,
|
'service_type': service_type, 'service_name': service_name,
|
||||||
'region_name': region_name})
|
'region_name': region_name})
|
||||||
elif service_name:
|
elif service_name:
|
||||||
msg = (_('%(endpoint_type)s endpoint for %(service_type)s service '
|
msg = ('%(endpoint_type)s endpoint for %(service_type)s service '
|
||||||
'named %(service_name)s not found') %
|
'named %(service_name)s not found' %
|
||||||
{'endpoint_type': endpoint_type,
|
{'endpoint_type': endpoint_type,
|
||||||
'service_type': service_type,
|
'service_type': service_type,
|
||||||
'service_name': service_name})
|
'service_name': service_name})
|
||||||
elif region_name:
|
elif region_name:
|
||||||
msg = (_('%(endpoint_type)s endpoint for %(service_type)s service '
|
msg = ('%(endpoint_type)s endpoint for %(service_type)s service '
|
||||||
'in %(region_name)s region not found') %
|
'in %(region_name)s region not found' %
|
||||||
{'endpoint_type': endpoint_type,
|
{'endpoint_type': endpoint_type,
|
||||||
'service_type': service_type, 'region_name': region_name})
|
'service_type': service_type, 'region_name': region_name})
|
||||||
else:
|
else:
|
||||||
msg = (_('%(endpoint_type)s endpoint for %(service_type)s service '
|
msg = ('%(endpoint_type)s endpoint for %(service_type)s service '
|
||||||
'not found') %
|
'not found' %
|
||||||
{'endpoint_type': endpoint_type,
|
{'endpoint_type': endpoint_type,
|
||||||
'service_type': service_type})
|
'service_type': service_type})
|
||||||
|
|
||||||
@ -213,7 +212,7 @@ class ServiceCatalogV2(ServiceCatalog):
|
|||||||
@classmethod
|
@classmethod
|
||||||
def from_token(cls, token):
|
def from_token(cls, token):
|
||||||
if 'access' not in token:
|
if 'access' not in token:
|
||||||
raise ValueError(_('Invalid token format for fetching catalog'))
|
raise ValueError('Invalid token format for fetching catalog')
|
||||||
|
|
||||||
return cls(token['access'].get('serviceCatalog', {}))
|
return cls(token['access'].get('serviceCatalog', {}))
|
||||||
|
|
||||||
@ -249,7 +248,7 @@ class ServiceCatalogV3(ServiceCatalog):
|
|||||||
@classmethod
|
@classmethod
|
||||||
def from_token(cls, token):
|
def from_token(cls, token):
|
||||||
if 'token' not in token:
|
if 'token' not in token:
|
||||||
raise ValueError(_('Invalid token format for fetching catalog'))
|
raise ValueError('Invalid token format for fetching catalog')
|
||||||
|
|
||||||
return cls(token['token'].get('catalog', {}))
|
return cls(token['token'].get('catalog', {}))
|
||||||
|
|
||||||
|
@ -28,7 +28,6 @@ from six.moves import urllib
|
|||||||
|
|
||||||
from keystoneauth import _utils as utils
|
from keystoneauth import _utils as utils
|
||||||
from keystoneauth import exceptions
|
from keystoneauth import exceptions
|
||||||
from keystoneauth.i18n import _, _LI, _LW
|
|
||||||
|
|
||||||
try:
|
try:
|
||||||
import netaddr
|
import netaddr
|
||||||
@ -51,10 +50,10 @@ def _positive_non_zero_float(argument_value):
|
|||||||
try:
|
try:
|
||||||
value = float(argument_value)
|
value = float(argument_value)
|
||||||
except ValueError:
|
except ValueError:
|
||||||
msg = _("%s must be a float") % argument_value
|
msg = "%s must be a float" % argument_value
|
||||||
raise argparse.ArgumentTypeError(msg)
|
raise argparse.ArgumentTypeError(msg)
|
||||||
if value <= 0:
|
if value <= 0:
|
||||||
msg = _("%s must be greater than 0") % argument_value
|
msg = "%s must be greater than 0" % argument_value
|
||||||
raise argparse.ArgumentTypeError(msg)
|
raise argparse.ArgumentTypeError(msg)
|
||||||
return value
|
return value
|
||||||
|
|
||||||
@ -326,7 +325,7 @@ class Session(object):
|
|||||||
auth_headers = self.get_auth_headers(auth)
|
auth_headers = self.get_auth_headers(auth)
|
||||||
|
|
||||||
if auth_headers is None:
|
if auth_headers is None:
|
||||||
msg = _('No valid authentication is available')
|
msg = 'No valid authentication is available'
|
||||||
raise exceptions.AuthorizationFailure(msg)
|
raise exceptions.AuthorizationFailure(msg)
|
||||||
|
|
||||||
headers.update(auth_headers)
|
headers.update(auth_headers)
|
||||||
@ -428,17 +427,17 @@ class Session(object):
|
|||||||
try:
|
try:
|
||||||
resp = self.session.request(method, url, **kwargs)
|
resp = self.session.request(method, url, **kwargs)
|
||||||
except requests.exceptions.SSLError as e:
|
except requests.exceptions.SSLError as e:
|
||||||
msg = _('SSL exception connecting to %(url)s: '
|
msg = 'SSL exception connecting to %(url)s: %(error)s' % {
|
||||||
'%(error)s') % {'url': url, 'error': e}
|
'url': url, 'error': e}
|
||||||
raise exceptions.SSLError(msg)
|
raise exceptions.SSLError(msg)
|
||||||
except requests.exceptions.Timeout:
|
except requests.exceptions.Timeout:
|
||||||
msg = _('Request to %s timed out') % url
|
msg = 'Request to %s timed out' % url
|
||||||
raise exceptions.ConnectTimeout(msg)
|
raise exceptions.ConnectTimeout(msg)
|
||||||
except requests.exceptions.ConnectionError:
|
except requests.exceptions.ConnectionError:
|
||||||
msg = _('Unable to establish connection to %s') % url
|
msg = 'Unable to establish connection to %s' % url
|
||||||
raise exceptions.ConnectFailure(msg)
|
raise exceptions.ConnectFailure(msg)
|
||||||
except requests.exceptions.RequestException as e:
|
except requests.exceptions.RequestException as e:
|
||||||
msg = _('Unexpected exception for %(url)s: %(error)s') % {
|
msg = 'Unexpected exception for %(url)s: %(error)s' % {
|
||||||
'url': url, 'error': e}
|
'url': url, 'error': e}
|
||||||
raise exceptions.UnknownConnectionError(msg, e)
|
raise exceptions.UnknownConnectionError(msg, e)
|
||||||
|
|
||||||
@ -446,7 +445,7 @@ class Session(object):
|
|||||||
if connect_retries <= 0:
|
if connect_retries <= 0:
|
||||||
raise
|
raise
|
||||||
|
|
||||||
logger.info(_LI('Failure: %(e)s. Retrying in %(delay).1fs.'),
|
logger.info('Failure: %(e)s. Retrying in %(delay).1fs.',
|
||||||
{'e': e, 'delay': connect_retry_delay})
|
{'e': e, 'delay': connect_retry_delay})
|
||||||
time.sleep(connect_retry_delay)
|
time.sleep(connect_retry_delay)
|
||||||
|
|
||||||
@ -473,8 +472,8 @@ class Session(object):
|
|||||||
try:
|
try:
|
||||||
location = resp.headers['location']
|
location = resp.headers['location']
|
||||||
except KeyError:
|
except KeyError:
|
||||||
logger.warn(_LW("Failed to redirect request to %s as new "
|
logger.warn("Failed to redirect request to %s as new "
|
||||||
"location was not provided."), resp.url)
|
"location was not provided.", resp.url)
|
||||||
else:
|
else:
|
||||||
# NOTE(jamielennox): We don't pass through connect_retry_delay.
|
# NOTE(jamielennox): We don't pass through connect_retry_delay.
|
||||||
# This request actually worked so we can reset the delay count.
|
# This request actually worked so we can reset the delay count.
|
||||||
@ -565,7 +564,7 @@ class Session(object):
|
|||||||
auth = self.auth
|
auth = self.auth
|
||||||
|
|
||||||
if not auth:
|
if not auth:
|
||||||
msg_fmt = _('An auth plugin is required to %s')
|
msg_fmt = 'An auth plugin is required to %s'
|
||||||
raise exceptions.MissingAuthPlugin(msg_fmt % msg)
|
raise exceptions.MissingAuthPlugin(msg_fmt % msg)
|
||||||
|
|
||||||
return auth
|
return auth
|
||||||
|
@ -26,7 +26,6 @@ from testtools import matchers
|
|||||||
from keystoneauth import adapter
|
from keystoneauth import adapter
|
||||||
from keystoneauth.auth import base
|
from keystoneauth.auth import base
|
||||||
from keystoneauth import exceptions
|
from keystoneauth import exceptions
|
||||||
from keystoneauth.i18n import _
|
|
||||||
from keystoneauth import session as client_session
|
from keystoneauth import session as client_session
|
||||||
from keystoneauth.tests.unit import utils
|
from keystoneauth.tests.unit import utils
|
||||||
|
|
||||||
@ -223,7 +222,7 @@ class SessionTests(utils.TestCase):
|
|||||||
session = client_session.Session()
|
session = client_session.Session()
|
||||||
|
|
||||||
# The exception should contain the URL and details about the SSL error
|
# The exception should contain the URL and details about the SSL error
|
||||||
msg = _('SSL exception connecting to %(url)s: %(error)s') % {
|
msg = 'SSL exception connecting to %(url)s: %(error)s' % {
|
||||||
'url': self.TEST_URL, 'error': error}
|
'url': self.TEST_URL, 'error': error}
|
||||||
self.assertRaisesRegex(exceptions.SSLError,
|
self.assertRaisesRegex(exceptions.SSLError,
|
||||||
msg,
|
msg,
|
||||||
|
Loading…
Reference in New Issue
Block a user