Issue when gnomekeyring is present but not the current backend

Issue was identified in the review for the previous
patch for bug 1116302. Took this chance to rename _IOError
to a better name (KeyringIOError)

Change-Id: I321353d519eaebea27617702f92ecafe2052eb8e
This commit is contained in:
Davanum Srinivas 2013-02-14 20:58:01 -05:00
parent d1d4f33aca
commit 132465231a
1 changed files with 7 additions and 5 deletions

View File

@ -35,9 +35,11 @@ try:
HAS_KEYRING = True
try:
if isinstance(keyring.get_keyring(), keyring.backend.GnomeKeyring):
_IOError = gnomekeyring.IOError
KeyringIOError = gnomekeyring.IOError
else:
KeyringIOError = IOError
except Exception:
_IOError = IOError
KeyringIOError = IOError
except ImportError:
pass
@ -151,7 +153,7 @@ class SecretsHelper(object):
block = keyring.get_password('novaclient_auth', self._make_key())
if block:
_token, management_url, _tenant_id = block.split('|', 2)
except (_IOError, ValueError):
except (KeyringIOError, ValueError):
pass
return management_url
@ -168,7 +170,7 @@ class SecretsHelper(object):
block = keyring.get_password('novaclient_auth', self._make_key())
if block:
token, _management_url, _tenant_id = block.split('|', 2)
except (_IOError, ValueError):
except (KeyringIOError, ValueError):
pass
return token
@ -181,7 +183,7 @@ class SecretsHelper(object):
block = keyring.get_password('novaclient_auth', self._make_key())
if block:
_token, _management_url, tenant_id = block.split('|', 2)
except (_IOError, ValueError):
except (KeyringIOError, ValueError):
pass
return tenant_id