summaryrefslogtreecommitdiff
path: root/src/leap/mx
diff options
context:
space:
mode:
Diffstat (limited to 'src/leap/mx')
-rw-r--r--src/leap/mx/__init__.py2
-rw-r--r--src/leap/mx/alias_resolver.py3
-rw-r--r--src/leap/mx/couchdbhelper.py2
-rw-r--r--src/leap/mx/mail_receiver.py16
4 files changed, 16 insertions, 7 deletions
diff --git a/src/leap/mx/__init__.py b/src/leap/mx/__init__.py
index df784db..2c4f106 100644
--- a/src/leap/mx/__init__.py
+++ b/src/leap/mx/__init__.py
@@ -14,9 +14,7 @@
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
-
"""
Module intialization file for leap.mx .
"""
-
__all__ = ['alias_resolver', 'couchdbhelper']
diff --git a/src/leap/mx/alias_resolver.py b/src/leap/mx/alias_resolver.py
index 68c6212..2074ee5 100644
--- a/src/leap/mx/alias_resolver.py
+++ b/src/leap/mx/alias_resolver.py
@@ -36,7 +36,8 @@ except ImportError:
class AliasResolverFactory(postfix.PostfixTCPMapDeferringDictServerFactory):
def __init__(self, couchdb, *args, **kwargs):
- postfix.PostfixTCPMapDeferringDictServerFactory.__init__(self, *args, **kwargs)
+ postfix.PostfixTCPMapDeferringDictServerFactory.__init__(
+ self, *args, **kwargs)
self._cdb = couchdb
def _to_str(self, result):
diff --git a/src/leap/mx/couchdbhelper.py b/src/leap/mx/couchdbhelper.py
index 7c4c8ce..02ef088 100644
--- a/src/leap/mx/couchdbhelper.py
+++ b/src/leap/mx/couchdbhelper.py
@@ -157,6 +157,7 @@ if __name__ == "__main__":
password="")
d = cdb.queryByLoginOrAlias("test1")
+
@d.addCallback
def right(result):
print "Should be an actual uuid:", result
@@ -164,6 +165,7 @@ if __name__ == "__main__":
print cdb.getPubKey(result)
d2 = cdb.queryByLoginOrAlias("asdjaoisdjoiqwjeoi")
+
@d2.addCallback
def wrong(result):
print "Should be None:", result
diff --git a/src/leap/mx/mail_receiver.py b/src/leap/mx/mail_receiver.py
index 49d4455..2c04863 100644
--- a/src/leap/mx/mail_receiver.py
+++ b/src/leap/mx/mail_receiver.py
@@ -72,7 +72,9 @@ class MailReceiver(Service):
for directory, recursive in self._directories:
log.msg("Watching %s --- Recursive: %s" % (directory, recursive))
- wm.watch(filepath.FilePath(directory), mask, callbacks=[self._process_incoming_email], recursive=recursive)
+ wm.watch(filepath.FilePath(directory), mask,
+ callbacks=[self._process_incoming_email],
+ recursive=recursive)
def _get_pubkey(self, uuid):
"""
@@ -127,7 +129,8 @@ class MailReceiver(Service):
doc.content = {
"_enc_scheme": EncryptionSchemes.PUBKEY,
- "_enc_json": openpgp.encrypt_asym(json.dumps(data), openpgp_key)
+ "_enc_json": openpgp.encrypt_asym(json.dumps(data),
+ openpgp_key)
}
return uuid, doc
@@ -198,6 +201,9 @@ class MailReceiver(Service):
owner = mail["To"]
if owner is None: # default to Delivered-To
owner = mail["Delivered-To"]
+ if owner is None:
+ log.err("Malformed mail, neither To: nor "
+ "Delivered-To: field")
owner = owner.split("@")[0]
owner = owner.split("+")[0]
log.msg("Mail owner: %s" % (owner,))
@@ -205,8 +211,10 @@ class MailReceiver(Service):
log.msg("%s received a new mail" % (owner,))
d = self._users_cdb.queryByLoginOrAlias(owner)
d.addCallbacks(self._get_pubkey, log.err)
- d.addCallbacks(self._encrypt_message, log.err, (owner, mail_data))
+ d.addCallbacks(self._encrypt_message, log.err,
+ (owner, mail_data))
d.addCallbacks(self._export_message, log.err)
- d.addCallbacks(self._conditional_remove, log.err, (filepath,))
+ d.addCallbacks(self._conditional_remove, log.err,
+ (filepath,))
d.addErrback(log.err)