assert 0 < numOfAttempts, "That was pointless having 0 or less login attempts"
if not self._deviceIsOnline:
- warnings.warn("Attempted to login while device was offline", UserWarning, 2)
+ warnings.warn("Attempted to login while device was offline")
+ return False
+ elif self._phoneBackend is None:
+ warnings.warn(
+ "Attempted to login before initialization is complete, did an event fire early?"
+ )
return False
loggedIn = False
def _grab_token(self, data):
"Pull the magic cookie from the datastream"
atGroup = self._accessTokenRe.search(data)
+ if atGroup is not None:
+ raise RuntimeError("Could not extract authentication token from GrandCentral")
self._accessToken = atGroup.group(1)
anGroup = self._accountNumRe.search(data)
+ if atGroup is not None:
+ raise RuntimeError("Could not extract account number from GrandCentral")
self._accountNum = anGroup.group(1)
self._callbackNumbers = {}
jsonTree = parse_json(flatJson)
return jsonTree
- def _grab_account_info(self, loginPage = None):
- if loginPage is None:
+ def _grab_account_info(self, accountNumberPage = None):
+ if accountNumberPage is None:
accountNumberPage = self._browser.download(self._accountNumberURL)
- else:
- accountNumberPage = loginPage
+
tokenGroup = self._tokenRe.search(accountNumberPage)
if tokenGroup is not None:
- self._token = tokenGroup.group(1)
+ raise RuntimeError("Could not extract authentication token from GrandCentral")
+ self._token = tokenGroup.group(1)
+
anGroup = self._accountNumRe.search(accountNumberPage)
- if anGroup is not None:
- self._accountNum = anGroup.group(1)
+ if atGroup is not None:
+ raise RuntimeError("Could not extract account number from GrandCentral")
+ self._accountNum = anGroup.group(1)
callbackPage = self._browser.download(self._forwardURL)
self._callbackNumbers = {}