예제 #1
0
def blocking(f, app_name, result_cb, error_cb):
    """Run f in a thread; return or throw an exception thru the callbacks."""
    d = deferToThread(f)
    # the calls in twisted will be called with the args in a diff order,
    # in order to follow the linux api, we swap them around with a lambda
    d.addCallback(lambda result, app: result_cb(app, result), app_name)
    d.addErrback(lambda err, app:
                 error_cb(app, except_to_errdict(err.value)), app_name)
예제 #2
0
 def _in_thread():
     """The part that runs inside the thread."""
     try:
         result_cb(app_name, f())
     except Exception, e:  # pylint: disable=W0703
         msg = "Exception while running DBus blocking code in a thread:"
         logger.exception(msg)
         error_cb(app_name, except_to_errdict(e))
예제 #3
0
 def f(*args):
     """Process arguments and call remote."""
     try:
         args = list(args)
         if args:
             args[-1] = except_to_errdict(args[-1].value)
         return handler.callRemote('execute', *args)
     # Yes, I want to catch everything
     # pylint: disable=W0703
     except Exception:
         logger.exception("Remote handler argument processing error:")
예제 #4
0
 def _process_failure(self, failure, app_name):
     """Process the 'failure' and emit CredentialsError."""
     self.emit_credentials_error(app_name, except_to_errdict(failure.value))
예제 #5
0
 def emit_password_change_error(self, app_name, raised_error):
     """Signal thrown when there's a problem sending the token."""
     logger.debug('SSOLogin: emitting PasswordChangeError with '
                  'app_name "%s" and error %r', app_name, raised_error)
     self.emit_signal('on_password_change_error', app_name,
                      except_to_errdict(raised_error.value))
예제 #6
0
 def emit_email_validation_error(self, app_name, raised_error):
     """Signal thrown when there's a problem validating the email."""
     logger.debug('SSOLogin: emitting EmailValidationError with '
                  'app_name "%s" and error %r', app_name, raised_error)
     self.emit_signal('on_email_validation_error', app_name,
                      except_to_errdict(raised_error.value))
예제 #7
0
 def emit_login_error(self, app_name, raised_error):
     """Signal thrown when there is a problem in the login."""
     logger.debug('SSOLogin: emitting LoginError with '
                  'app_name "%s" and error %r', app_name, raised_error)
     self.emit_signal('on_login_error', app_name,
                      except_to_errdict(raised_error.value))
예제 #8
0
 def emit_user_registration_error(self, app_name, raised_error):
     """Signal thrown when there's a problem registering the user."""
     logger.debug('SSOLogin: emitting UserRegistrationError with '
                  'app_name "%s" and error %r', app_name, raised_error)
     self.emit_signal('on_user_registration_error', app_name,
                      except_to_errdict(raised_error.value))
예제 #9
0
 def emit_captcha_generation_error(self, app_name, raised_error):
     """Signal thrown when there's a problem generating the captcha."""
     logger.debug('SSOLogin: emitting CaptchaGenerationError with '
                  'app_name "%s" and error %r', app_name, raised_error)
     self.emit_signal('on_captcha_generation_error', app_name,
                      except_to_errdict(raised_error.value))