# under mit license
# Oct 6, 2006; sri
import appuifw, time, messaging
gcal_sms_addr = "48368"
monthnames = [u"Jan", u"Feb", u"Mar", u"Apr", u"May", u"Jun",
u"Jul", u"Aug", u"Sep", u"Oct", u"Nov", u"Dec"]
def gsend(x):
x = unicode(x)
messaging.sms_send(gcal_sms_addr, x)
print "Message sent\n", x
# spits out messages like
# "nov 2 2108 12:00pm try out ruby" to gcal
def create_new():
now = time.time()
year, month, day, hour, min = time.localtime(now)[:5]
date = appuifw.query(u"Date:", "date", now)
if date is None:
return
ttime = appuifw.query(u"Time:", "time", float(3600*hour+60*min))
if ttime is None:
return
event = appuifw.query(u"Event:", "text")
if not event:
return
year2, month2, day2 = time.localtime(date)[:3]
hour2, sec2 = divmod(int(ttime), 3600)
min2, _ = divmod(sec2, 60)
if hour2 >= 12:
ampm = "pm"
else:
ampm = "am"
gevent = "%s %d %d %d:%02d%s %s" % (
monthnames[month2-1],
day2,
year2,
hour2,
min2,
ampm,
event)
gsend(gevent)
def next_event():
gsend("next")
def todays_events():
gsend("day")
def tommorows_events():
gsend("nday")
def main():
# Currently available Google calendar
# actions via SMS
menuitems = [(u"Create new", create_new),
(u"Next", next_event),
(u"Today's", todays_events),
(u"Tommorow's", tommorows_events)]
sel = appuifw.popup_menu([x[0] for x in menuitems],
u"GCal actions")
if sel is None:
return
menuitems[sel][1]()
if __name__ == "__main__":
main()
07 October 2006
Google Calendar w/ Python on Nokia 6600
I, recently: downloaded Python for my Nokia 6600 and also started using Google Calendar. After seeing Google Calendar's SMS interface I made it a little easier to use from my cell:
(this works under nokia 6600 and python for s60 2nd edition, 1.3.1)