Fixing the section
[gc-dialer] / src / gv_backend.py
index a7e5823..aca5b9b 100644 (file)
@@ -369,27 +369,24 @@ class GVDialer(object):
                jsonTree = parse_json(flatJson)
                return jsonTree
 
-       def _grab_account_info(self, accountNumberPage = None):
-               if accountNumberPage is None:
-                       accountNumberPage = self._browser.download(self._accountNumberURL)
+       def _grab_account_info(self):
+               page = self._browser.download(self._forwardURL)
 
-               tokenGroup = self._tokenRe.search(accountNumberPage)
-               if tokenGroup is not None:
-                       raise RuntimeError("Could not extract authentication token from GrandCentral")
+               tokenGroup = self._tokenRe.search(page)
+               if tokenGroup is None:
+                       raise RuntimeError("Could not extract authentication token from GoogleVoice")
                self._token = tokenGroup.group(1)
 
-               anGroup = self._accountNumRe.search(accountNumberPage)
-               if atGroup is not None:
-                       raise RuntimeError("Could not extract account number from GrandCentral")
+               anGroup = self._accountNumRe.search(page)
+               if anGroup is None:
+                       raise RuntimeError("Could not extract account number from GoogleVoice")
                self._accountNum = anGroup.group(1)
 
-               callbackPage = self._browser.download(self._forwardURL)
                self._callbackNumbers = {}
-               for match in self._callbackRe.finditer(callbackPage):
-                       self._callbackNumbers[match.group(2)] = match.group(1)
-
-               if len(self._callbackNumber) == 0:
-                       self.set_sane_callback()
+               for match in self._callbackRe.finditer(page):
+                       callbackNumber = match.group(2)
+                       callbackName = match.group(1)
+                       self._callbackNumbers[callbackNumber] = callbackName
 
 
 def test_backend(username, password):
@@ -401,8 +398,8 @@ def test_backend(username, password):
        print "Token: ", backend._token
        print "Account: ", backend.get_account_number()
        print "Callback: ", backend.get_callback_number()
-       # print "All Callback: ",
-       # pprint.pprint(backend.get_callback_numbers())
+       print "All Callback: ",
+       pprint.pprint(backend.get_callback_numbers())
        # print "Recent: ",
        # pprint.pprint(list(backend.get_recent()))
        # print "Contacts: ",