Hardware Reference
In-Depth Information
Now, we will print the details of the retrieved events:
for i, an_event in enumerate(feed.entry):
print '\t%s. %s' % (i, an_event.title.text,)
for a_when in an_event.when:
print '\t\tStart time: %s' % (a_when.start_time,)
print '\t\tEnd time: %s' % (a_when.end_time,)
The preceding example was borrowed from the documentation of the
Google Calendar API. When executed, the output would be something
like the following:
0. Sai
Start time: 2013-05-12T11:30:00.000-05:00
End time: 2013-05-12T12:30:00.000-05:00
1. Event at Firegrill house
Start time: 2013-04-24T18:30:00.000-05:00
End time: 2013-04-24T19:30:00.000-05:00
2. Chicago Hardware Startup Meetup - FIRST MEETING
Start time: 2013-01-23T18:30:00.000-06:00
End time: 2013-01-23T21:00:00.000-06:00
3. Freescale SABRE Lite Board
Start time: 2013-01-30T12:00:00.000-06:00
End time: 2013-01-30T13:00:00.000-06:00
5.
Since we are able to retrieve and parse the events on the Google Calendar, we will
try to blink an LED to remind us about the events and appointments.
We will get started with importing the RPi.GPIO module in the same file:
import calendar_special
import time
import datetime
import RPi.GPIO as gpio
Since we used pin 17 for the e-mail alerts, let's use pin 24 for reminders
and events.
The events can be retrieved from Google Calendar as follows:
feed = calendar_special.calendar_query() # retrieve events
from calendar
for i, an_event in enumerate(feed.entry):
for a_when in an_event.when: #We retrieve the start time
and end time for each appointment/event
try:
start_time = datetime.datetime.strptime(a_when.
start_time.split(".")[0], "%Y-%m-%dT%H:%M:%S")
 
Search WWH ::




Custom Search