summaryrefslogtreecommitdiff
path: root/service/pixelated/config
diff options
context:
space:
mode:
authorOla Bini <ola@olabini.se>2017-01-20 15:20:51 -0200
committerOla Bini <ola@olabini.se>2017-01-20 15:20:51 -0200
commitc427efc53d2f373e5a149f4d2a4118ab9a85a15b (patch)
treecbb45f90617825584d8b71531c5976e28ba5addf /service/pixelated/config
parentb47fa1461c3dd919a193337afb035c14695cb900 (diff)
Rebase previous PR on current master - see PR #915 for details
Diffstat (limited to 'service/pixelated/config')
-rw-r--r--service/pixelated/config/leap.py13
-rw-r--r--service/pixelated/config/sessions.py21
2 files changed, 13 insertions, 21 deletions
diff --git a/service/pixelated/config/leap.py b/service/pixelated/config/leap.py
index 6b9ebf28..52a70f3e 100644
--- a/service/pixelated/config/leap.py
+++ b/service/pixelated/config/leap.py
@@ -90,9 +90,16 @@ class BootstrapUserServices(object):
@defer.inlineCallbacks
def setup(self, user_auth, password, language='pt-BR'):
- leap_session = yield create_leap_session(self._provider, user_auth.username, password, user_auth)
- yield self._setup_user_services(leap_session)
- yield self._add_welcome_email(leap_session, language)
+ leap_session = None
+ try:
+ leap_session = yield create_leap_session(self._provider, user_auth.username, password, user_auth)
+ yield self._setup_user_services(leap_session)
+ yield self._add_welcome_email(leap_session, language)
+ except Exception as e:
+ log.warn('{0}: {1}. Closing session for user: {2}'.format(e.__class__.__name__, e, user_auth.username))
+ if leap_session:
+ leap_session.close()
+ raise e
@defer.inlineCallbacks
def _setup_user_services(self, leap_session):
diff --git a/service/pixelated/config/sessions.py b/service/pixelated/config/sessions.py
index eba55100..2bad3e32 100644
--- a/service/pixelated/config/sessions.py
+++ b/service/pixelated/config/sessions.py
@@ -118,15 +118,6 @@ class LeapSessionFactory(object):
cert = SmtpClientCertificate(self._provider, auth, self._user_path(auth.uuid))
return cert.cert_path()
- def _create_dir(self, path):
- try:
- os.makedirs(path)
- except OSError as exc:
- if exc.errno == errno.EEXIST and os.path.isdir(path):
- pass
- else:
- raise
-
def _user_path(self, user_uuid):
return os.path.join(leap_config.leap_home, user_uuid)
@@ -172,13 +163,7 @@ class LeapSession(object):
@defer.inlineCallbacks
def finish_bootstrap(self):
- try:
- yield self.keymanager.generate_openpgp_key()
- except UploadKeyError as e:
- logger.warn('{0}: {1}. Closing session for user: {2}'.format(e.__class__.__name__, e, self.account_email()))
- self.close()
- raise
-
+ yield self.keymanager.generate_openpgp_key()
yield self._create_account(self.soledad, self.user_auth.uuid)
self.incoming_mail_fetcher = yield self._create_incoming_mail_fetcher(
self.keymanager,
@@ -236,8 +221,8 @@ class LeapSession(object):
def sync(self):
try:
return self.soledad.sync()
- except:
- traceback.print_exc(file=sys.stderr)
+ except Exception as e:
+ logger.error(e)
raise