From 1eebbfcad803f25681f777c70f97602e2ef295f0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1s=20Touceda?= Date: Thu, 8 Aug 2013 13:44:50 -0300 Subject: Do not fail if nickserver request fails --- changes/bug_dont_fail_if_nickserver_does | 1 + src/leap/keymanager/__init__.py | 21 +++++++++++++++------ 2 files changed, 16 insertions(+), 6 deletions(-) create mode 100644 changes/bug_dont_fail_if_nickserver_does diff --git a/changes/bug_dont_fail_if_nickserver_does b/changes/bug_dont_fail_if_nickserver_does new file mode 100644 index 00000000..6e44d931 --- /dev/null +++ b/changes/bug_dont_fail_if_nickserver_does @@ -0,0 +1 @@ + o If a nickserver request fails in any way, notify and continue. \ No newline at end of file diff --git a/src/leap/keymanager/__init__.py b/src/leap/keymanager/__init__.py index d24e08e4..e6122ffb 100644 --- a/src/leap/keymanager/__init__.py +++ b/src/leap/keymanager/__init__.py @@ -20,6 +20,7 @@ Key Manager is a Nicknym agent for LEAP client. """ +import logging import requests from leap.common.check import leap_assert, leap_assert_type @@ -38,6 +39,8 @@ from leap.keymanager.openpgp import ( OpenPGPScheme, ) +logger = logging.getLogger(__name__) + # # The Key Manager @@ -170,12 +173,18 @@ class KeyManager(object): @raise KeyNotFound: If the key was not found on nickserver. """ # request keys from the nickserver - server_keys = self._get( - self._nickserver_uri, {'address': address}).json() - # insert keys in local database - if self.OPENPGP_KEY in server_keys: - self._wrapper_map[OpenPGPKey].put_ascii_key( - server_keys['openpgp']) + res = None + try: + res = self._get(self._nickserver_uri, {'address': address}) + server_keys = res.json() + # insert keys in local database + if self.OPENPGP_KEY in server_keys: + self._wrapper_map[OpenPGPKey].put_ascii_key( + server_keys['openpgp']) + except Exception as e: + logger.warning("Error retrieving the keys: %r" % (e,)) + if res: + logger.warning("%s" % (res.content,)) # # key management -- cgit v1.2.3