From adb5941df991543b4383817a3e6f30daad42879c Mon Sep 17 00:00:00 2001 From: Davanum Srinivas Date: Mon, 18 Mar 2013 12:02:25 -0400 Subject: [PATCH] catch NoKeyringDaemonError from gnomekeyring Looks like we need to add more exceptions, start to maintain a tuple of exceptions Change-Id: I3a027f5d2d8f82fe397e3096ff82358040f3729e --- novaclient/shell.py | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/novaclient/shell.py b/novaclient/shell.py index 8b4aea512..ccd0a45a6 100644 --- a/novaclient/shell.py +++ b/novaclient/shell.py @@ -31,17 +31,18 @@ import pkgutil import sys HAS_KEYRING = False +all_errors = ValueError try: import keyring HAS_KEYRING = True try: if isinstance(keyring.get_keyring(), keyring.backend.GnomeKeyring): import gnomekeyring - KeyringIOError = gnomekeyring.IOError - else: - KeyringIOError = IOError + all_errors = (ValueError, + gnomekeyring.IOError, + gnomekeyring.NoKeyringDaemonError) except Exception: - KeyringIOError = IOError + pass except ImportError: pass @@ -156,7 +157,7 @@ class SecretsHelper(object): block = keyring.get_password('novaclient_auth', self._make_key()) if block: _token, management_url, _tenant_id = block.split('|', 2) - except (KeyringIOError, ValueError): + except all_errors: pass return management_url @@ -173,7 +174,7 @@ class SecretsHelper(object): block = keyring.get_password('novaclient_auth', self._make_key()) if block: token, _management_url, _tenant_id = block.split('|', 2) - except (KeyringIOError, ValueError): + except all_errors: pass return token @@ -186,7 +187,7 @@ class SecretsHelper(object): block = keyring.get_password('novaclient_auth', self._make_key()) if block: _token, _management_url, tenant_id = block.split('|', 2) - except (KeyringIOError, ValueError): + except all_errors: pass return tenant_id