diff options
Diffstat (limited to 'src/leap/bitmask/keymanager')
-rw-r--r-- | src/leap/bitmask/keymanager/__init__.py | 31 | ||||
-rw-r--r-- | src/leap/bitmask/keymanager/keys.py | 5 | ||||
-rw-r--r-- | src/leap/bitmask/keymanager/openpgp.py | 12 |
3 files changed, 24 insertions, 24 deletions
diff --git a/src/leap/bitmask/keymanager/__init__.py b/src/leap/bitmask/keymanager/__init__.py index 146bcd2..aafb9ce 100644 --- a/src/leap/bitmask/keymanager/__init__.py +++ b/src/leap/bitmask/keymanager/__init__.py @@ -25,15 +25,14 @@ import tempfile import json import urllib -from leap.common import ca_bundle -from twisted.web import client -from twisted.web._responses import NOT_FOUND - -import logging +from urlparse import urlparse +from twisted.logger import Logger from twisted.internet import defer -from urlparse import urlparse +from twisted.web import client +from twisted.web._responses import NOT_FOUND +from leap.common import ca_bundle from leap.common.check import leap_assert from leap.common.http import HTTPClient from leap.common.events import emit_async, catalog @@ -47,7 +46,7 @@ from leap.bitmask.keymanager.errors import ( from leap.bitmask.keymanager.validation import ValidationLevels, can_upgrade from leap.bitmask.keymanager.openpgp import OpenPGPScheme -logger = logging.getLogger(__name__) +logger = Logger() # @@ -144,15 +143,15 @@ class KeyManager(object): except KeyNotFound: raise except IOError as e: - logger.warning("HTTP error retrieving key: %r" % (e,)) - logger.warning("%s" % (content,)) + logger.warn("HTTP error retrieving key: %r" % (e,)) + logger.warn("%s" % (content,)) raise KeyNotFound(e.message), None, sys.exc_info()[2] except ValueError as v: - logger.warning("Invalid JSON data from key: %s" % (uri,)) + logger.warn("invalid JSON data from key: %s" % (uri,)) raise KeyNotFound(v.message + ' - ' + uri), None, sys.exc_info()[2] except Exception as e: - logger.warning("Error retrieving key: %r" % (e,)) + logger.warn("error retrieving key: %r" % (e,)) raise KeyNotFound(e.message), None, sys.exc_info()[2] # Responses are now text/plain, although it's json anyway, but # this will fail when it shouldn't @@ -176,7 +175,7 @@ class KeyManager(object): def check_404(response): if response.code == NOT_FOUND: message = '%s: %s key not found.' % (response.code, address) - logger.warning(message) + logger.warn(message) raise KeyNotFound(message), None, sys.exc_info()[2] return response @@ -204,7 +203,7 @@ class KeyManager(object): try: content = yield self._async_client.request(str(uri), 'GET') except Exception as e: - logger.warning("There was a problem fetching key: %s" % (e,)) + logger.warn("There was a problem fetching key: %s" % (e,)) raise KeyNotFound(uri) if not content: raise KeyNotFound(uri) @@ -239,12 +238,12 @@ class KeyManager(object): body=str(data), headers=headers) except Exception as e: - logger.warning("Error uploading key: %r" % (e,)) + logger.warn("Error uploading key: %r" % (e,)) raise e if 'error' in res: # FIXME: That's a workaround for 500, # we need to implement a readBody to assert response code - logger.warning("Error uploading key: %r" % (res,)) + logger.warn("Error uploading key: %r" % (res,)) raise Exception(res) @memoized_method(invalidation=300) @@ -759,7 +758,7 @@ class KeyManager(object): :raise UnsupportedKeyTypeError: if invalid key type """ - logger.info("Fetch key for %s from %s" % (address, uri)) + logger.info("fetch key for %s from %s" % (address, uri)) ascii_content = yield self._get_with_combined_ca_bundle(uri) # XXX parse binary keys diff --git a/src/leap/bitmask/keymanager/keys.py b/src/leap/bitmask/keymanager/keys.py index 2ea4c8e..45a7d72 100644 --- a/src/leap/bitmask/keymanager/keys.py +++ b/src/leap/bitmask/keymanager/keys.py @@ -18,18 +18,19 @@ Abstact key type and encryption scheme representations. """ import json -import logging import re import time from datetime import datetime +from twisted.logger import Logger + from leap.bitmask.keymanager import errors from leap.bitmask.keymanager.wrapper import TempGPGWrapper from leap.bitmask.keymanager.validation import ValidationLevels from leap.bitmask.keymanager import documents as doc -logger = logging.getLogger(__name__) +logger = Logger() # diff --git a/src/leap/bitmask/keymanager/openpgp.py b/src/leap/bitmask/keymanager/openpgp.py index b07ac41..43c8d93 100644 --- a/src/leap/bitmask/keymanager/openpgp.py +++ b/src/leap/bitmask/keymanager/openpgp.py @@ -17,7 +17,6 @@ """ Infrastructure for using OpenPGP keys in Key Manager. """ -import logging import os import re import tempfile @@ -30,6 +29,7 @@ from multiprocessing import cpu_count from gnupg.gnupg import GPGUtilities from twisted.internet import defer from twisted.internet.threads import deferToThread +from twisted.logger import Logger from leap.common.check import leap_assert, leap_assert_type, leap_check from leap.bitmask.keymanager import errors @@ -61,7 +61,7 @@ from leap.bitmask.keymanager.documents import ( ) -logger = logging.getLogger(__name__) +logger = Logger() # @@ -497,8 +497,8 @@ class OpenPGPScheme(object): if len(docs) == 0: raise errors.KeyNotFound(key) elif len(docs) > 1: - logger.warning("There is more than one key for fingerprint %s" - % key.fingerprint) + logger.warn("There is more than one key for fingerprint %s" + % key.fingerprint) has_deleted = False deferreds = [] @@ -585,7 +585,7 @@ class OpenPGPScheme(object): self._assert_gpg_result_ok(result) defer.returnValue(result.data) except errors.GPGError as e: - logger.warning('Failed to encrypt: %s.' % str(e)) + logger.warn('Failed to encrypt: %s.' % str(e)) raise errors.EncryptError() @defer.inlineCallbacks @@ -631,7 +631,7 @@ class OpenPGPScheme(object): defer.returnValue((result.data, sign_valid)) except errors.GPGError as e: - logger.warning('Failed to decrypt: %s.' % str(e)) + logger.warn('Failed to decrypt: %s.' % str(e)) raise errors.DecryptError(str(e)) def is_encrypted(self, data): |