diff options
author | Kali Kaneko <kali@leap.se> | 2014-09-16 11:43:58 -0500 |
---|---|---|
committer | Kali Kaneko <kali@leap.se> | 2014-09-16 11:43:58 -0500 |
commit | 509f76c21c7c847dc4111847a3585be7bb67e350 (patch) | |
tree | ee7b2d6bf5921fee9de6e27b0a7a6d97ab559364 /scripts/profiling/mail/mail.py | |
parent | 22d3a8d4c6a1e652109378245989f4f6a71d1f42 (diff) | |
parent | 2f1ee76a7169abc100efdf706f12a0abf6032f04 (diff) |
Merge remote-tracking branch 'drebs-github/add-benchmarking-scripts' into develop
Diffstat (limited to 'scripts/profiling/mail/mail.py')
-rw-r--r-- | scripts/profiling/mail/mail.py | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/scripts/profiling/mail/mail.py b/scripts/profiling/mail/mail.py new file mode 100644 index 00000000..8504c762 --- /dev/null +++ b/scripts/profiling/mail/mail.py @@ -0,0 +1,50 @@ +import os +import threading + +from twisted.internet import reactor + +from leap.mail.imap.service import imap +from leap.keymanager import KeyManager + +from util import log + + +class IMAPServerThread(threading.Thread): + def __init__(self, imap_service): + threading.Thread.__init__(self) + self._imap_service = imap_service + + def run(self): + self._imap_service.start_loop() + reactor.run() + + def stop(self): + self._imap_service.stop() + reactor.stop() + + +def get_imap_server(soledad, uuid, address, token): + log("Starting imap... ", line_break=False) + + keymanager = KeyManager(address, '', soledad, token=token, uid=uuid) + with open( + os.path.join( + os.path.dirname(__file__), + 'keys/5447A9AD50E3075ECCE432711B450E665FE63573.sec'), 'r') as f: + pubkey, privkey = keymanager.parse_openpgp_ascii_key(f.read()) + keymanager.put_key(privkey) + + imap_service, imap_port, imap_factory = imap.run_service( + soledad, keymanager, userid=address, offline=False) + + imap_service.start_loop() + log("started.") + return imap_service + + #imap_server = IMAPServerThread(imap_service) + #try: + # imap_server.start() + #except Exception as e: + # print str(e) + + #return imap_server |