from browser_emu import MozillaEmulator
-import socket
-
try:
import simplejson
except ImportError:
simplejson = None
-socket.setdefaulttimeout(5)
-
_TRUE_REGEX = re.compile("true")
_FALSE_REGEX = re.compile("false")
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)
+ if tokenGroup is None:
+ 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 None:
+ raise RuntimeError("Could not extract account number from GrandCentral")
+ self._accountNum = anGroup.group(1)
callbackPage = self._browser.download(self._forwardURL)
self._callbackNumbers = {}