From d1d4f33aca4f9753dd31972ea53ddc831b52fbfc Mon Sep 17 00:00:00 2001 From: Davanum Srinivas Date: Mon, 11 Feb 2013 15:55:33 -0500 Subject: [PATCH] Fix IOError with gnomekeyring.find_network_password_sync find_network_password_sync throws a gnomekeyring.IOError when a non-root user tries to run nova client from a ssh console. If we don't catch this exception nova client throws the traceback (shown in the bug report) and stops. If we catch this exception (just like we catch ValueError), and return None, Nova client executes just fine. Fixes LP# 1116302 Change-Id: If6937b3f8eafb1dc55224b2ca2bd0f93ae07f8c6 --- novaclient/shell.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/novaclient/shell.py b/novaclient/shell.py index b00b28604..537fef3af 100644 --- a/novaclient/shell.py +++ b/novaclient/shell.py @@ -33,6 +33,11 @@ try: import keyring HAS_KEYRING = True + try: + if isinstance(keyring.get_keyring(), keyring.backend.GnomeKeyring): + _IOError = gnomekeyring.IOError + except Exception: + _IOError = IOError except ImportError: pass @@ -146,7 +151,7 @@ def management_url(self): block = keyring.get_password('novaclient_auth', self._make_key()) if block: _token, management_url, _tenant_id = block.split('|', 2) - except ValueError: + except (_IOError, ValueError): pass return management_url @@ -163,7 +168,7 @@ def auth_token(self): block = keyring.get_password('novaclient_auth', self._make_key()) if block: token, _management_url, _tenant_id = block.split('|', 2) - except ValueError: + except (_IOError, ValueError): pass return token @@ -176,7 +181,7 @@ def tenant_id(self): block = keyring.get_password('novaclient_auth', self._make_key()) if block: _token, _management_url, tenant_id = block.split('|', 2) - except ValueError: + except (_IOError, ValueError): pass return tenant_id