def _authenticate(self): ''' authentication main function ''' self.authenticated.clear() while not self.authenticated.isSet(): if not self.token: self.rtm = createRTM( self.PUBLIC_KEY, self.PRIVATE_KEY, self.token) subprocess.Popen(['xdg-open', self.rtm.getAuthURL()]) self.auth_confirm() try: time.sleep(1) self.token = self.rtm.getToken() except Exception: # something went wrong. self.token = None continue try: if self._login(): self.authenticated.set() self.on_auth() except IOError: BackendSignals().backend_failed(self.get_id(), BackendSignals.ERRNO_NETWORK)
def _authenticate(self): """ authentication main function """ self.authenticated.clear() while not self.authenticated.isSet(): if not self.token: self.rtm = createRTM(self.PUBLIC_KEY, self.PRIVATE_KEY, self.token) Gio.AppInfo.launch_default_for_uri(self.rtm.getAuthURL(), None) self.auth_confirm() try: time.sleep(1) self.token = self.rtm.getToken() except Exception: # something went wrong. self.token = None continue try: if self._login(): self.authenticated.set() self.on_auth() except IOError: BackendSignals().backend_failed(self.get_id(), BackendSignals.ERRNO_NETWORK)
def _authenticate(self): ''' authentication main function ''' self.authenticated.clear() while not self.authenticated.isSet(): if not self.token: self.rtm = createRTM(self.PUBLIC_KEY, self.PRIVATE_KEY, self.token) subprocess.Popen(['xdg-open', self.rtm.getAuthURL()]) self.auth_confirm() try: time.sleep(1) self.token = self.rtm.getToken() except Exception: # something went wrong. self.token = None continue try: if self._login(): self.authenticated.set() self.on_auth() except IOError: BackendSignals().backend_failed(self.get_id(), BackendSignals.ERRNO_NETWORK)
def _login(self): ''' Tries to establish a connection to rtm with a token got from the authentication process ''' try: self.rtm = createRTM(self.PUBLIC_KEY, self.PRIVATE_KEY, self.token) self.timeline = self.rtm.timelines.create().timeline return True except (RTMError, RTMAPIError), e: Log.error("RTM ERROR" + str(e))
def _login(self): """ Tries to establish a connection to rtm with a token got from the authentication process """ try: self.rtm = createRTM(self.PUBLIC_KEY, self.PRIVATE_KEY, self.token) self.timeline = self.rtm.timelines.create().timeline return True except (RTMError, RTMAPIError): log.exception("RTM ERROR:") return False