12 def get_missed(backend):
13 missedPage = backend._browser.download(backend._missedCallsURL)
14 missedJson = pprint.pformat(backend._grab_json(missedPage))
18 def get_voicemail(backend):
19 voicemailPage = backend._browser.download(backend._voicemailURL)
20 voicemailJson = pprint.pformat(backend._grab_json(voicemailPage))
25 smsPage = backend._browser.download(backend._smsURL)
26 smsJson = pprint.pformat(backend._grab_json(smsPage))
30 def is_changed(backend, type, get_material):
31 currentMaterial = get_material(backend)
32 previousSnapshotPath = os.path.join(constants._data_path_, "snapshot_%s.old.json" % type)
33 currentSnapshotPath = os.path.join(constants._data_path_, "snapshot_%s.json" % type)
36 os.remove(previousSnapshotPath)
38 # check if failed purely because the old file didn't exist, which is fine
42 os.rename(currentSnapshotPath, previousSnapshotPath)
45 # check if failed purely because the old file didn't exist, which is fine
48 previousExists = False
50 currentSnapshot = file(currentSnapshotPath, "w")
52 currentSnapshot.write(currentMaterial)
54 currentSnapshot.close()
56 if not previousExists:
59 seemEqual = filecmp.cmp(previousSnapshotPath, currentSnapshotPath)
64 gvCookiePath = os.path.join(constants._data_path_, "gv_cookies.txt")
65 backend = gv_backend.GVDialer(gvCookiePath)
70 loggedIn = backend.is_authed()
72 config = ConfigParser.SafeConfigParser()
73 config.read(constants._user_settings_)
78 config.get(constants.__pretty_app_name__, "bin_blob_%i" % i)
82 base64.b64decode(blob)
85 username, password = tuple(creds)
86 loggedIn = backend.login(username, password)
87 except ConfigParser.NoOptionError, e:
89 except ConfigParser.NoSectionError, e:
93 notifyOnMissed = config.getboolean("2 - Account Info", "notifyOnMissed")
94 notifyOnVoicemail = config.getboolean("2 - Account Info", "notifyOnVoicemail")
95 notifyOnSms = config.getboolean("2 - Account Info", "notifyOnSms")
96 except ConfigParser.NoOptionError, e:
97 notifyOnMissed = False
98 notifyOnVoicemail = False
100 except ConfigParser.NoSectionError, e:
101 notifyOnMissed = False
102 notifyOnVoicemail = False
108 notifySources.append(("missed", get_missed))
109 if notifyOnVoicemail:
110 notifySources.append(("voicemail", get_voicemail))
112 notifySources.append(("sms", get_sms))
115 for type, get_material in (
116 ("missed", get_missed),
117 ("voicemail", get_voicemail),
120 if is_changed(backend, type, get_material):
125 led = led_handler.LedHandler()
129 if __name__ == "__main__":