Stop using function deprecated in py34
Python 3.4 has deprecated some functions: LOG.warn: DeprecationWarning: The 'warn' method is deprecated, use 'warning' instead SafeConfigParser: DeprecationWarning: The SafeConfigParser class has been renamed to ConfigParser in Python 3.2. This alias will be removed in future versions. Use ConfigParser directly instead. ConfigParser's readfp: DeprecationWarning: This method will be removed in future versions. Use 'parser.read_file()' instead. Change-Id: I82829e05682931128eb6fcaf0c5e215671d1173d
This commit is contained in:
parent
57d389da8a
commit
c94f403490
@ -46,6 +46,7 @@ from pycadf import reporterstep
|
|||||||
from pycadf import resource
|
from pycadf import resource
|
||||||
from pycadf import tag
|
from pycadf import tag
|
||||||
from pycadf import timestamp
|
from pycadf import timestamp
|
||||||
|
import six
|
||||||
from six.moves import configparser
|
from six.moves import configparser
|
||||||
from six.moves.urllib import parse as urlparse
|
from six.moves.urllib import parse as urlparse
|
||||||
import webob.dec
|
import webob.dec
|
||||||
@ -79,6 +80,16 @@ AuditMap = collections.namedtuple('AuditMap',
|
|||||||
'default_target_endpoint_type'])
|
'default_target_endpoint_type'])
|
||||||
|
|
||||||
|
|
||||||
|
# NOTE(blk-u): Compatibility for Python 2. SafeConfigParser and
|
||||||
|
# SafeConfigParser.readfp are deprecated in Python 3. Remove this when we drop
|
||||||
|
# support for Python 2.
|
||||||
|
if six.PY2:
|
||||||
|
class ConfigParser(configparser.SafeConfigParser):
|
||||||
|
read_file = configparser.SafeConfigParser.readfp
|
||||||
|
else:
|
||||||
|
ConfigParser = configparser.ConfigParser
|
||||||
|
|
||||||
|
|
||||||
class OpenStackAuditApi(object):
|
class OpenStackAuditApi(object):
|
||||||
|
|
||||||
def __init__(self, cfg_file):
|
def __init__(self, cfg_file):
|
||||||
@ -90,8 +101,8 @@ class OpenStackAuditApi(object):
|
|||||||
|
|
||||||
if cfg_file:
|
if cfg_file:
|
||||||
try:
|
try:
|
||||||
map_conf = configparser.SafeConfigParser()
|
map_conf = ConfigParser()
|
||||||
map_conf.readfp(open(cfg_file))
|
map_conf.read_file(open(cfg_file))
|
||||||
|
|
||||||
try:
|
try:
|
||||||
default_target_endpoint_type = map_conf.get(
|
default_target_endpoint_type = map_conf.get(
|
||||||
|
@ -735,11 +735,11 @@ class AuthProtocol(object):
|
|||||||
verified = self._verify_signed_token(token,
|
verified = self._verify_signed_token(token,
|
||||||
token_hashes)
|
token_hashes)
|
||||||
except exceptions.CertificateConfigError:
|
except exceptions.CertificateConfigError:
|
||||||
self._LOG.warn(_LW('Fetch certificate config failed, '
|
self._LOG.warning(_LW('Fetch certificate config failed, '
|
||||||
'fallback to online validation.'))
|
'fallback to online validation.'))
|
||||||
except exc.RevocationListError:
|
except exc.RevocationListError:
|
||||||
self._LOG.warn(_LW('Fetch revocation list failed, '
|
self._LOG.warning(_LW('Fetch revocation list failed, '
|
||||||
'fallback to online validation.'))
|
'fallback to online validation.'))
|
||||||
|
|
||||||
if verified is not None:
|
if verified is not None:
|
||||||
data = jsonutils.loads(verified)
|
data = jsonutils.loads(verified)
|
||||||
@ -764,7 +764,7 @@ class AuthProtocol(object):
|
|||||||
return auth_ref, data
|
return auth_ref, data
|
||||||
except (exceptions.ConnectionRefused, exceptions.RequestTimeout):
|
except (exceptions.ConnectionRefused, exceptions.RequestTimeout):
|
||||||
self._LOG.debug('Token validation failure.', exc_info=True)
|
self._LOG.debug('Token validation failure.', exc_info=True)
|
||||||
self._LOG.warn(_LW('Authorization failed for token'))
|
self._LOG.warning(_LW('Authorization failed for token'))
|
||||||
raise exc.InvalidToken(_('Token authorization failed'))
|
raise exc.InvalidToken(_('Token authorization failed'))
|
||||||
except exc.ServiceError:
|
except exc.ServiceError:
|
||||||
raise
|
raise
|
||||||
@ -772,7 +772,7 @@ class AuthProtocol(object):
|
|||||||
self._LOG.debug('Token validation failure.', exc_info=True)
|
self._LOG.debug('Token validation failure.', exc_info=True)
|
||||||
if token_hashes:
|
if token_hashes:
|
||||||
self._token_cache.store_invalid(token_hashes[0])
|
self._token_cache.store_invalid(token_hashes[0])
|
||||||
self._LOG.warn(_LW('Authorization failed for token'))
|
self._LOG.warning(_LW('Authorization failed for token'))
|
||||||
raise exc.InvalidToken(_('Token authorization failed'))
|
raise exc.InvalidToken(_('Token authorization failed'))
|
||||||
|
|
||||||
def _build_user_headers(self, auth_ref):
|
def _build_user_headers(self, auth_ref):
|
||||||
|
Loading…
x
Reference in New Issue
Block a user