import state_machine
import util.go_utils as gobject_utils
+import util.misc as misc_utils
_moduleLogger = logging.getLogger(__name__)
def __on_login_success(self, user_success):
- def _actual_success(self, *args, **kwds):
+ @misc_utils.log_exception(_moduleLogger)
+ def _actual_success(*args, **kwds):
self._masterStateMachine.start()
user_success(*args, **kwds)
if self._username is None and self._password is None:
_moduleLogger.info("Hasn't even attempted to login yet")
return False
- elif self._backend.is_authed():
- return True
else:
- try:
- loggedIn = self._backend.login(self._username, self._password)
- except RuntimeError, e:
- _moduleLogger.exception("Re-authenticating and erroring")
- loggedIn = False
- if loggedIn:
- return True
- else:
- _moduleLogger.info("Login failed")
- self.logout()
- return False
+ isLoggedIn = self._backend.is_authed()
+ if not isLoggedIn:
+ _moduleLogger.error("Not logged in anymore")
+ return isLoggedIn
def set_dnd(self, doNotDisturb):
self._backend.set_dnd(doNotDisturb)
@property
def backend(self):
+ assert self.is_logged_in()
return self._backend
@property