summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordrebs <drebs@leap.se>2013-08-08 23:37:37 +0200
committerdrebs <drebs@leap.se>2013-08-08 23:37:37 +0200
commitcc2cda450925721614eec467e5f8dd6849a50dd8 (patch)
tree6568604868d8a9964113c057811cdbe0dbf868ab
parent52178f62cc880c19593a4fe15efbff812ad0b47d (diff)
parent4bdec73025a8d923782ee99f1096bbd1bbd93c1f (diff)
Merge branch 'bug/support_nicknym_potential_problems' into develop
-rw-r--r--keymanager/changes/bug_dont_fail_if_nickserver_does1
-rw-r--r--keymanager/src/leap/keymanager/__init__.py21
2 files changed, 16 insertions, 6 deletions
diff --git a/keymanager/changes/bug_dont_fail_if_nickserver_does b/keymanager/changes/bug_dont_fail_if_nickserver_does
new file mode 100644
index 0000000..6e44d93
--- /dev/null
+++ b/keymanager/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/keymanager/src/leap/keymanager/__init__.py b/keymanager/src/leap/keymanager/__init__.py
index d24e08e..e6122ff 100644
--- a/keymanager/src/leap/keymanager/__init__.py
+++ b/keymanager/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