From d2a6fd962a608e72a1367eada8fd791183da4cc1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1s=20Touceda?= Date: Tue, 26 Nov 2013 15:46:05 -0300 Subject: Add tester script to ease debugging problematic mails. --- src/leap/mx/tester.py | 46 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100644 src/leap/mx/tester.py (limited to 'src') diff --git a/src/leap/mx/tester.py b/src/leap/mx/tester.py new file mode 100644 index 0000000..05d2d05 --- /dev/null +++ b/src/leap/mx/tester.py @@ -0,0 +1,46 @@ +import ConfigParser +import sys +import os + +from twisted.internet import reactor, defer +from twisted.python import filepath, log + +from leap.mx import couchdbhelper +from leap.mx.mail_receiver import MailReceiver + +if __name__ == "__main__": + log.startLogging(sys.stdout) + fullpath = os.path.realpath(sys.argv[1]) + + log.msg("Starting test for %s..." % (fullpath,)) + + config_file = "/etc/leap/mx.conf" + + config = ConfigParser.ConfigParser() + config.read(config_file) + + user = config.get("couchdb", "user") + password = config.get("couchdb", "password") + + server = config.get("couchdb", "server") + port = config.get("couchdb", "port") + + cdb = couchdbhelper.ConnectedCouchDB(server, + port=port, + dbName="identities", + username=user, + password=password) + + # Mail receiver + mail_couch_url_prefix = "http://%s:%s@%s:%s" % (user, + password, + server, + port) + + mr = MailReceiver(mail_couch_url_prefix, cdb, []) + fpath = filepath.FilePath(fullpath) + + d = mr._process_incoming_email(None, fpath, 0) + d.addCallback(lambda x: reactor.stop()) + + reactor.run() -- cgit v1.2.3