diff options
author | Tomas Touceda <chiiph@leap.se> | 2013-05-03 17:05:53 -0300 |
---|---|---|
committer | Tomas Touceda <chiiph@leap.se> | 2013-05-03 17:05:53 -0300 |
commit | aed42557a7e8a17561c225426f66db1187006d9c (patch) | |
tree | 8b6408a1a8611cc567d0f8e7d579d501905aa0dc /src/leap | |
parent | d7478834794cd9e73d43732da28c8bde5c9b8801 (diff) |
Add setup script and init.d script
Also, some pep8 fixes
Diffstat (limited to 'src/leap')
-rw-r--r-- | src/leap/__init__.py | 28 | ||||
-rw-r--r-- | src/leap/mx/__init__.py | 2 | ||||
-rw-r--r-- | src/leap/mx/alias_resolver.py | 3 | ||||
-rw-r--r-- | src/leap/mx/couchdbhelper.py | 2 | ||||
-rw-r--r-- | src/leap/mx/mail_receiver.py | 16 |
5 files changed, 22 insertions, 29 deletions
diff --git a/src/leap/__init__.py b/src/leap/__init__.py index ff2d8a1..f48ad10 100644 --- a/src/leap/__init__.py +++ b/src/leap/__init__.py @@ -1,22 +1,6 @@ -# -*- encoding: utf-8 -*- -# __init__.py -# Copyright (C) 2013 LEAP -# -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# 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. -""" - -__all__ = ['mx'] +# See http://peak.telecommunity.com/DevCenter/setuptools#namespace-packages +try: + __import__('pkg_resources').declare_namespace(__name__) +except ImportError: + from pkgutil import extend_path + __path__ = extend_path(__path__, __name__) 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) |