summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKali Kaneko <kali@leap.se>2013-08-05 17:03:07 +0200
committerKali Kaneko <kali@leap.se>2013-08-05 17:03:07 +0200
commitdeab7f6ce43a638638fc306e37c23a2d2787bf9d (patch)
treec74119ec3adb596439997d838232a3eaa4f0137b
parent562a2a57a049bac91a860aac7ee52f4549c39808 (diff)
use the right import path
-rw-r--r--mail/src/leap/mail/imap/fetch.py22
-rw-r--r--mail/src/leap/mail/imap/service/imap.py20
2 files changed, 20 insertions, 22 deletions
diff --git a/mail/src/leap/mail/imap/fetch.py b/mail/src/leap/mail/imap/fetch.py
index 48a45e6..566873b 100644
--- a/mail/src/leap/mail/imap/fetch.py
+++ b/mail/src/leap/mail/imap/fetch.py
@@ -1,15 +1,15 @@
import logging
import json
+import ssl
from twisted.python import log
from twisted.internet import defer
from twisted.internet.threads import deferToThread
from leap.common.check import leap_assert, leap_assert_type
+from leap.keymanager import openpgp
from leap.soledad import Soledad
-from leap.common.keymanager import openpgp
-
logger = logging.getLogger(__name__)
@@ -67,13 +67,17 @@ class LeapIncomingMail(object):
def _sync_soledad(self):
log.msg('syncing soledad...')
logger.debug('in soledad sync')
- #import ipdb; ipdb.set_trace()
- self._soledad.sync()
- gen, doclist = self._soledad.get_all_docs()
- #logger.debug("there are %s docs" % (len(doclist),))
- log.msg("there are %s docs" % (len(doclist),))
- return doclist
+ try:
+ self._soledad.sync()
+ gen, doclist = self._soledad.get_all_docs()
+ #logger.debug("there are %s docs" % (len(doclist),))
+ log.msg("there are %s docs" % (len(doclist),))
+ return doclist
+ except ssl.SSLError as exc:
+ logger.warning('SSL Error while syncing soledad: %r' % (exc,))
+ except Exception as exc:
+ logger.warning('Error while syncing soledad: %r' % (exc,))
def _sync_soledad_err(self, f):
log.err("error syncing soledad: %s" % (f.value,))
@@ -81,6 +85,8 @@ class LeapIncomingMail(object):
def _process_doclist(self, doclist):
log.msg('processing doclist')
+ if not doclist:
+ return
for doc in doclist:
keys = doc.content.keys()
if self.ENC_SCHEME_KEY in keys and self.ENC_JSON_KEY in keys:
diff --git a/mail/src/leap/mail/imap/service/imap.py b/mail/src/leap/mail/imap/service/imap.py
index 49d54e3..6a8d37f 100644
--- a/mail/src/leap/mail/imap/service/imap.py
+++ b/mail/src/leap/mail/imap/service/imap.py
@@ -28,7 +28,7 @@ from twisted.mail import imap4
from twisted.python import log
from leap.common.check import leap_assert, leap_assert_type
-from leap.common.keymanager import KeyManager
+from leap.keymanager import KeyManager
from leap.mail.imap.server import SoledadBackedAccount
from leap.mail.imap.fetch import LeapIncomingMail
from leap.soledad import Soledad
@@ -127,6 +127,9 @@ class LeapIMAPFactory(ServerFactory):
def run_service(*args, **kwargs):
"""
Main entry point to run the service from the client.
+
+ :returns: the LoopingCall instance that will have to be stoppped
+ before shutting down the client.
"""
leap_assert(len(args) == 2)
soledad, keymanager = args
@@ -139,11 +142,6 @@ def run_service(*args, **kwargs):
uuid = soledad._get_uuid()
factory = LeapIMAPFactory(uuid, soledad)
- # ---- for application framework
- #application = service.Application("LEAP IMAP4 Local Service")
- #imapService = internet.TCPServer(port, factory)
- #imapService.setServiceParent(application)
-
from twisted.internet import reactor
reactor.listenTCP(port, factory)
@@ -155,13 +153,7 @@ def run_service(*args, **kwargs):
lc = LoopingCall(fetcher.fetch)
lc.start(check_period)
- # ---- for application framework
- #internet.TimerService(
- #check_period,
- #fetcher.fetch).setServiceParent(application)
-
- logger.debug('----------------------------------------')
logger.debug("IMAP4 Server is RUNNING in port %s" % (port,))
- #log.msg("IMAP4 Server is RUNNING in port %s" % (port,))
- #return application
+ # XXX maybe return both fetcher and lc??
+ return lc