From bc84433a06a742c3b29e115fb9e88c86df0f2b1c Mon Sep 17 00:00:00 2001 From: Tulio Casagrande Date: Mon, 9 Jan 2017 16:13:39 -0200 Subject: Log user's current key for easier debug Related with: #815 --- service/pixelated/bitmask_libraries/keymanager.py | 25 +++++++++-------------- 1 file changed, 10 insertions(+), 15 deletions(-) (limited to 'service/pixelated/bitmask_libraries') diff --git a/service/pixelated/bitmask_libraries/keymanager.py b/service/pixelated/bitmask_libraries/keymanager.py index 84e3f6aa..28d5f9db 100644 --- a/service/pixelated/bitmask_libraries/keymanager.py +++ b/service/pixelated/bitmask_libraries/keymanager.py @@ -48,16 +48,19 @@ class Keymanager(object): def generate_openpgp_key(self): current_key = yield self._key_exists(self._email) if not current_key: - yield self._generate_key_and_send_to_leap() + current_key = yield self._generate_key_and_send_to_leap() elif current_key.needs_renewal(DEFAULT_EXTENSION_THRESHOLD): - yield self._regenerate_key_and_send_to_leap() + current_key = yield self._regenerate_key_and_send_to_leap() + + logger.info("Current key for {}: {}".format(self._email, current_key.fingerprint)) @defer.inlineCallbacks def _regenerate_key_and_send_to_leap(self): logger.info("Regenerating keys - this could take a while...") - yield self.keymanager.regenerate_key() + key = yield self.keymanager.regenerate_key() try: - yield self._send_key_to_leap() + yield self.keymanager.send_key() + defer.returnValue(key) except Exception as e: # what to be done when upload key error raise UploadKeyError(e.message) @@ -65,9 +68,10 @@ class Keymanager(object): @defer.inlineCallbacks def _generate_key_and_send_to_leap(self): logger.info("Generating keys - this could take a while...") - yield self._gen_key() + key = yield self.keymanager.gen_key() try: - yield self._send_key_to_leap() + yield self.keymanager.send_key() + defer.returnValue(key) except Exception as e: yield self.delete_key_pair() raise UploadKeyError(e.message) @@ -85,15 +89,6 @@ class Keymanager(object): key = yield self.keymanager.get_key(email, private=private, fetch_remote=fetch_remote) defer.returnValue(key) - @defer.inlineCallbacks - def _gen_key(self): - key = yield self.keymanager.gen_key() - defer.returnValue(key) - - @defer.inlineCallbacks - def _send_key_to_leap(self): - yield self.keymanager.send_key() - @defer.inlineCallbacks def delete_key_pair(self): private_key = yield self.get_key(self._email, private=True, fetch_remote=False) -- cgit v1.2.3