self._accountNumRe = re.compile(r"""<b class="ms\d">(.{14})</b></div>""")
self._callbackRe = re.compile(r"""\s+(.*?):\s*(.*?)<br\s*/>\s*$""", re.M)
+ self._isDndURL = "https://www.google.com/voice/m/donotdisturb"
+ self._isDndRe = re.compile(r"""<input.*?id="doNotDisturb".*?checked="(.*?)"\s*/>""")
+ self._setDndURL = "https://www.google.com/voice/m/savednd"
+
self._gvDialingStrRe = re.compile("This may take a few seconds", re.M)
self._clicktocallURL = "https://www.google.com/voice/m/sendcall"
self._sendSmsURL = "https://www.google.com/voice/m/sendsms"
self._browser.cookies.clear()
self._browser.cookies.save()
+ def is_dnd(self):
+ try:
+ isDndPage = self._browser.download(self._isDndURL)
+ except urllib2.URLError, e:
+ _moduleLogger.exception("Translating error: %s" % str(e))
+ raise NetworkError("%s is not accesible" % self._isDndURL)
+
+ dndGroup = self._isDndRe.search(isDndPage)
+ if dndGroup is None:
+ return False
+ dndStatus = dndGroup.group(1)
+ isDnd = True if dndStatus.strip().lower() == "true" else False
+ return isDnd
+
+ def set_dnd(self, doNotDisturb):
+ dndPostData = urllib.urlencode({
+ "doNotDisturb": 1 if doNotDisturb else 0,
+ "_rnr_se": self._token,
+ })
+
+ try:
+ dndPage = self._browser.download(self._setDndURL, dndPostData)
+ except urllib2.URLError, e:
+ _moduleLogger.exception("Translating error: %s" % str(e))
+ raise NetworkError("%s is not accesible" % self._setDndURL)
+
def dial(self, number):
"""
This is the main function responsible for initating the callback
if not backend.is_authed():
print "Login?: ", backend.login(username, password)
print "Authenticated: ", backend.is_authed()
+ print "Is Dnd: ", backend.is_dnd()
+ #print "Setting Dnd", backend.set_dnd(True)
+ #print "Is Dnd: ", backend.is_dnd()
+ #print "Setting Dnd", backend.set_dnd(False)
+ #print "Is Dnd: ", backend.is_dnd()
#print "Token: ", backend._token
#print "Account: ", backend.get_account_number()
("forward", backend._forwardURL),
("token", backend._tokenURL),
("login", backend._loginURL),
+ ("isdnd", backend._isDndURL),
("contacts", backend._contactsURL),
("voicemail", backend._voicemailURL),