Unsure when this got introduced, how strange
[theonering] / src / gvoice / session.py
index 597c7e3..5fb5a95 100644 (file)
@@ -10,6 +10,7 @@ import conversations
 import state_machine
 
 import util.go_utils as gobject_utils
+import util.misc as misc_utils
 
 
 _moduleLogger = logging.getLogger(__name__)
@@ -162,7 +163,8 @@ class Session(object):
 
        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)
 
@@ -180,20 +182,11 @@ class Session(object):
                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)
@@ -209,6 +202,7 @@ class Session(object):
 
        @property
        def backend(self):
+               assert self.is_logged_in()
                return self._backend
 
        @property