Stop using function deprecated in Python 3
Python 3 deprecated the logger.warn method in favor of warning. DeprecationWarning: The 'warn' method is deprecated, use 'warning' instead Change-Id: Idbd4de3c7c631fb2c235701c9b300c37a90d9538
This commit is contained in:
@@ -208,9 +208,10 @@ class BaseIdentityPlugin(base.BaseAuthPlugin):
|
||||
|
||||
else:
|
||||
if not service_type:
|
||||
LOG.warn(_LW('Plugin cannot return an endpoint without '
|
||||
'knowing the service type that is required. Add '
|
||||
'service_type to endpoint filtering data.'))
|
||||
LOG.warning(_LW(
|
||||
'Plugin cannot return an endpoint without knowing the '
|
||||
'service type that is required. Add service_type to '
|
||||
'endpoint filtering data.'))
|
||||
return None
|
||||
|
||||
if not interface:
|
||||
@@ -243,9 +244,10 @@ class BaseIdentityPlugin(base.BaseAuthPlugin):
|
||||
# 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
|
||||
# the best default but we need it for now.
|
||||
LOG.warn(_LW('Failed to contact the endpoint at %s for discovery. '
|
||||
'Fallback to using that endpoint as the base url.'),
|
||||
url)
|
||||
LOG.warning(_LW(
|
||||
'Failed to contact the endpoint at %s for discovery. Fallback '
|
||||
'to using that endpoint as the base url.'),
|
||||
url)
|
||||
else:
|
||||
url = disc.url_for(version)
|
||||
|
||||
|
@@ -130,9 +130,9 @@ class BaseGenericPlugin(base.BaseIdentityPlugin):
|
||||
except (exceptions.DiscoveryFailure,
|
||||
exceptions.HTTPError,
|
||||
exceptions.ConnectionError):
|
||||
LOG.warn(_LW('Discovering versions from the identity service '
|
||||
'failed when creating the password plugin. '
|
||||
'Attempting to determine version from URL.'))
|
||||
LOG.warning(_LW('Discovering versions from the identity service '
|
||||
'failed when creating the password plugin. '
|
||||
'Attempting to determine version from URL.'))
|
||||
|
||||
url_parts = urlparse.urlparse(self.auth_url)
|
||||
path = url_parts.path.lower()
|
||||
|
@@ -750,8 +750,8 @@ class AuthProtocol(object):
|
||||
return token
|
||||
else:
|
||||
if not self.delay_auth_decision:
|
||||
self.LOG.warn('Unable to find authentication token'
|
||||
' in headers')
|
||||
self.LOG.warning('Unable to find authentication token'
|
||||
' in headers')
|
||||
self.LOG.debug('Headers: %s', env)
|
||||
raise InvalidUserToken('Unable to find token in headers')
|
||||
|
||||
@@ -804,8 +804,8 @@ class AuthProtocol(object):
|
||||
if self.cert_file and self.key_file:
|
||||
kwargs['cert'] = (self.cert_file, self.key_file)
|
||||
elif self.cert_file or self.key_file:
|
||||
self.LOG.warn('Cannot use only a cert or key file. '
|
||||
'Please provide both. Ignoring.')
|
||||
self.LOG.warning('Cannot use only a cert or key file. '
|
||||
'Please provide both. Ignoring.')
|
||||
|
||||
kwargs['verify'] = self.ssl_ca_file or True
|
||||
if self.ssl_insecure:
|
||||
@@ -822,7 +822,8 @@ class AuthProtocol(object):
|
||||
self.LOG.error('HTTP connection exception: %s', e)
|
||||
raise NetworkError('Unable to communicate with keystone')
|
||||
# NOTE(vish): sleep 0.5, 1, 2
|
||||
self.LOG.warn('Retrying on HTTP connection exception: %s', e)
|
||||
self.LOG.warning('Retrying on HTTP connection exception: %s',
|
||||
e)
|
||||
time.sleep(2.0 ** retry / 2)
|
||||
retry += 1
|
||||
|
||||
@@ -896,12 +897,12 @@ class AuthProtocol(object):
|
||||
datetime_expiry = timeutils.parse_isotime(expiry)
|
||||
return (token, timeutils.normalize_time(datetime_expiry))
|
||||
except (AssertionError, KeyError):
|
||||
self.LOG.warn(
|
||||
self.LOG.warning(
|
||||
'Unexpected response from keystone service: %s', data)
|
||||
raise ServiceError('invalid json response')
|
||||
except (ValueError):
|
||||
data['access']['token']['id'] = '<SANITIZED>'
|
||||
self.LOG.warn(
|
||||
self.LOG.warning(
|
||||
'Unable to parse expiration time from token: %s', data)
|
||||
raise ServiceError('invalid json response')
|
||||
|
||||
@@ -948,13 +949,13 @@ class AuthProtocol(object):
|
||||
return data
|
||||
except NetworkError:
|
||||
self.LOG.debug('Token validation failure.', exc_info=True)
|
||||
self.LOG.warn('Authorization failed for token')
|
||||
self.LOG.warning('Authorization failed for token')
|
||||
raise InvalidUserToken('Token authorization failed')
|
||||
except Exception:
|
||||
self.LOG.debug('Token validation failure.', exc_info=True)
|
||||
if token_id:
|
||||
self._token_cache.store_invalid(token_id)
|
||||
self.LOG.warn('Authorization failed for token')
|
||||
self.LOG.warning('Authorization failed for token')
|
||||
raise InvalidUserToken('Token authorization failed')
|
||||
|
||||
def _build_user_headers(self, token_info):
|
||||
@@ -1143,7 +1144,7 @@ class AuthProtocol(object):
|
||||
if response.status_code == 200:
|
||||
return data
|
||||
if response.status_code == 404:
|
||||
self.LOG.warn('Authorization failed for token')
|
||||
self.LOG.warning('Authorization failed for token')
|
||||
raise InvalidUserToken('Token authorization failed')
|
||||
if response.status_code == 401:
|
||||
self.LOG.info(
|
||||
@@ -1156,7 +1157,7 @@ class AuthProtocol(object):
|
||||
self.LOG.info('Retrying validation')
|
||||
return self.verify_uuid_token(user_token, False)
|
||||
else:
|
||||
self.LOG.warn('Invalid user token. Keystone response: %s', data)
|
||||
self.LOG.warning('Invalid user token. Keystone response: %s', data)
|
||||
|
||||
raise InvalidUserToken()
|
||||
|
||||
|
@@ -455,8 +455,8 @@ class Session(object):
|
||||
try:
|
||||
location = resp.headers['location']
|
||||
except KeyError:
|
||||
logger.warn(_LW("Failed to redirect request to %s as new "
|
||||
"location was not provided."), resp.url)
|
||||
logger.warning(_LW("Failed to redirect request to %s as new "
|
||||
"location was not provided."), resp.url)
|
||||
else:
|
||||
# NOTE(jamielennox): We don't pass through connect_retry_delay.
|
||||
# This request actually worked so we can reset the delay count.
|
||||
|
@@ -927,7 +927,7 @@ class CommonAuthTokenMiddlewareTest(object):
|
||||
self.msg = None
|
||||
self.debugmsg = None
|
||||
|
||||
def warn(self, msg=None, *args, **kwargs):
|
||||
def warning(self, msg=None, *args, **kwargs):
|
||||
self.msg = msg
|
||||
|
||||
def debug(self, msg=None, *args, **kwargs):
|
||||
|
@@ -331,7 +331,7 @@ class positional(object):
|
||||
if self._enforcement == self.EXCEPT:
|
||||
raise TypeError(message)
|
||||
elif self._enforcement == self.WARN:
|
||||
logger.warn(message)
|
||||
logger.warning(message)
|
||||
|
||||
return func(*args, **kwargs)
|
||||
|
||||
|
Reference in New Issue
Block a user