Don't ignore logger exception

Change-Id: I4a5001bf47b5910c1a543cbe5462758381274eb0
This commit is contained in:
Ondřej Nový 2016-10-29 15:14:29 +02:00
parent 6f6380ffc8
commit bb377d790d
2 changed files with 6 additions and 18 deletions

View File

@ -78,10 +78,7 @@ class Swauth(object):
if not swift_version.at_least(SWIFT_MIN_VERSION): if not swift_version.at_least(SWIFT_MIN_VERSION):
msg = ("Your Swift installation is too old (%s). You need at " msg = ("Your Swift installation is too old (%s). You need at "
"least %s." % (swift.__version__, SWIFT_MIN_VERSION)) "least %s." % (swift.__version__, SWIFT_MIN_VERSION))
try: self.logger.critical(msg)
self.logger.critical(msg)
except Exception:
pass
raise ValueError(msg) raise ValueError(msg)
self.log_headers = conf.get('log_headers', 'no').lower() in TRUE_VALUES self.log_headers = conf.get('log_headers', 'no').lower() in TRUE_VALUES
self.reseller_prefix = conf.get('reseller_prefix', 'AUTH').strip() self.reseller_prefix = conf.get('reseller_prefix', 'AUTH').strip()
@ -99,20 +96,14 @@ class Swauth(object):
self.swauth_remote = self.swauth_remote.rstrip('/') self.swauth_remote = self.swauth_remote.rstrip('/')
if not self.swauth_remote: if not self.swauth_remote:
msg = _('Invalid swauth_remote set in conf file! Exiting.') msg = _('Invalid swauth_remote set in conf file! Exiting.')
try: self.logger.critical(msg)
self.logger.critical(msg)
except Exception:
pass
raise ValueError(msg) raise ValueError(msg)
self.swauth_remote_parsed = urlparse(self.swauth_remote) self.swauth_remote_parsed = urlparse(self.swauth_remote)
if self.swauth_remote_parsed.scheme not in ('http', 'https'): if self.swauth_remote_parsed.scheme not in ('http', 'https'):
msg = _('Cannot handle protocol scheme %(schema)s ' msg = _('Cannot handle protocol scheme %(schema)s '
'for url %(url)s!') % \ 'for url %(url)s!') % \
(self.swauth_remote_parsed.scheme, repr(self.swauth_remote)) (self.swauth_remote_parsed.scheme, repr(self.swauth_remote))
try: self.logger.critical(msg)
self.logger.critical(msg)
except Exception:
pass
raise ValueError(msg) raise ValueError(msg)
self.swauth_remote_timeout = int(conf.get('swauth_remote_timeout', 10)) self.swauth_remote_timeout = int(conf.get('swauth_remote_timeout', 10))
self.auth_account = '%s.auth' % self.reseller_prefix self.auth_account = '%s.auth' % self.reseller_prefix
@ -146,10 +137,7 @@ class Swauth(object):
if not self.super_admin_key and not self.swauth_remote: if not self.super_admin_key and not self.swauth_remote:
msg = _('No super_admin_key set in conf file; Swauth ' msg = _('No super_admin_key set in conf file; Swauth '
'administration features will be disabled.') 'administration features will be disabled.')
try: self.logger.warning(msg)
self.logger.warning(msg)
except Exception:
pass
self.token_life = int(conf.get('token_life', 86400)) self.token_life = int(conf.get('token_life', 86400))
self.max_token_life = int(conf.get('max_token_life', self.token_life)) self.max_token_life = int(conf.get('max_token_life', self.token_life))
self.timeout = int(conf.get('node_timeout', 10)) self.timeout = int(conf.get('node_timeout', 10))

View File

@ -29,10 +29,10 @@ setenv = VIRTUAL_ENV={envdir}
commands = commands =
flake8 swauth test flake8 swauth test
flake8 --filename=swauth* bin flake8 --filename=swauth* bin
bandit -r swauth -s B110,B309 bandit -r swauth -s B309
[testenv:bandit] [testenv:bandit]
commands = bandit -r swauth -s B110,B309 commands = bandit -r swauth -s B309
[testenv:venv] [testenv:venv]
commands = {posargs} commands = {posargs}