From f844d2de4ce4582737ce02a0c9c5e0b2ff4dd026 Mon Sep 17 00:00:00 2001 From: Tomas Touceda Date: Thu, 2 May 2013 13:44:08 -0300 Subject: Several fixes according to the review comments --- src/leap/mx/couchdbhelper.py | 17 +++++------------ 1 file changed, 5 insertions(+), 12 deletions(-) (limited to 'src/leap/mx/couchdbhelper.py') diff --git a/src/leap/mx/couchdbhelper.py b/src/leap/mx/couchdbhelper.py index 2f6b548..7c4c8ce 100644 --- a/src/leap/mx/couchdbhelper.py +++ b/src/leap/mx/couchdbhelper.py @@ -20,8 +20,6 @@ Classes for working with CouchDB or BigCouch instances which store email alias maps, user UUIDs, and GPG keyIDs. """ -import logging - from functools import partial try: @@ -32,12 +30,11 @@ except ImportError: try: from twisted.internet import defer + 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 ConnectedCouchDB(client.CouchDB): """ @@ -84,9 +81,9 @@ class ConnectedCouchDB(client.CouchDB): @param data: response from the listDB command @type data: array """ - logger.msg("Available databases:") + log.msg("Available databases:") for database in data: - logger.msg(" * %s" % (database,)) + log.msg(" * %s" % (database,)) def createDB(self, dbName): """ @@ -119,7 +116,7 @@ class ConnectedCouchDB(client.CouchDB): reduce=False, include_docs=True) - d.addCallbacks(partial(self._get_uuid, alias), logger.error) + d.addCallbacks(partial(self._get_uuid, alias), log.err) return d @@ -138,14 +135,10 @@ class ConnectedCouchDB(client.CouchDB): for row in result["rows"]: if row["key"] == alias: uuid = row["id"] - try: - self._cache[uuid] = row["doc"]["public_key"] - except: - pass # no public key for this user + self._cache[uuid] = row["doc"].get("public_key", None) return uuid return None - def getPubKey(self, uuid): pubkey = None try: -- cgit v1.2.3