diff options
author | Tomas Touceda <chiiph@leap.se> | 2013-05-02 13:44:08 -0300 |
---|---|---|
committer | Tomas Touceda <chiiph@leap.se> | 2013-05-07 14:02:12 -0300 |
commit | 860329613b205708dc7a4b04bcaf39b9bd24fec6 (patch) | |
tree | 9b759eaa8826141efa0ee50eb845e77e91dc8502 /src/leap/mx/alias_resolver.py | |
parent | 9042a0f5d7d6cee5bacf8085328a7a29ae99df11 (diff) |
Several fixes according to the review comments
Diffstat (limited to 'src/leap/mx/alias_resolver.py')
-rw-r--r-- | src/leap/mx/alias_resolver.py | 28 |
1 files changed, 13 insertions, 15 deletions
diff --git a/src/leap/mx/alias_resolver.py b/src/leap/mx/alias_resolver.py index 3f93f0d..68c6212 100644 --- a/src/leap/mx/alias_resolver.py +++ b/src/leap/mx/alias_resolver.py @@ -24,18 +24,15 @@ TODO: controlling concurrent connections and throttling resource consumption. """ -import logging - try: # TODO: we should probably use the system alias somehow # from twisted.mail import alias from twisted.protocols import postfix + from twisted.python import log except ImportError: print "This software requires Twisted. Please see the README file" print "for instructions on getting required dependencies." -logger = logging.getLogger(__name__) - class AliasResolverFactory(postfix.PostfixTCPMapDeferringDictServerFactory): def __init__(self, couchdb, *args, **kwargs): @@ -46,23 +43,24 @@ class AliasResolverFactory(postfix.PostfixTCPMapDeferringDictServerFactory): if isinstance(result, unicode): result = result.encode("utf8") if result is None: - logger.debug("Result not found") + log.msg("Result not found") return result def get(self, key): - orig_key = key try: - logger.debug("Processing key: %s" % (key,)) + log.msg("Processing key: %s" % (key,)) if key.find("@") == -1: - logger.debug("Ignoring key since it's not an email address") + log.msg("Ignoring key since it's not an email address") return None key = key.split("@")[0] key = key.split("+")[0] - logger.debug("Final key to query: %s" % (key,)) - except Exception as e: - key = orig_key - logger.exception("%s" % (e,)) - d = self._cdb.queryByLoginOrAlias(key) - d.addCallback(self._to_str) - return d + log.msg("Final key to query: %s" % (key,)) + d = self._cdb.queryByLoginOrAlias(key) + d.addCallback(self._to_str) + d.addErrback(log.err) + return d + except: + log.err() + + return None |