Merge lp:~minakov/calendar-indicator/all-calendars into lp:calendar-indicator/precise
- all-calendars
- Merge into trunk
Proposed by
Vladimir Minakov
Status: | Needs review |
---|---|
Proposed branch: | lp:~minakov/calendar-indicator/all-calendars |
Merge into: | lp:calendar-indicator/precise |
Diff against target: |
405 lines (+243/-75) 3 files modified
src/calendar-indicator.py (+51/-73) src/comun.py (+2/-2) src/googlecalendar.py (+190/-0) |
To merge this branch: | bzr merge lp:~minakov/calendar-indicator/all-calendars |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
atareao-team | Pending | ||
Review via email: mp+95446@code.launchpad.net |
Commit message
Description of the change
support all calendars
To post a comment you must log in.
- 19. By Vladimir Minakov
-
Fix bugs
Unmerged revisions
- 19. By Vladimir Minakov
-
Fix bugs
- 18. By Vladimir Minakov
-
All calendars
- 17. By Vladimir Minakov
-
All calendars
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1 | === modified file 'src/calendar-indicator.py' | |||
2 | --- src/calendar-indicator.py 2012-02-19 20:33:42 +0000 | |||
3 | +++ src/calendar-indicator.py 2012-03-01 20:44:18 +0000 | |||
4 | @@ -44,7 +44,7 @@ | |||
5 | 44 | # | 44 | # |
6 | 45 | import comun | 45 | import comun |
7 | 46 | from configurator import Configuration | 46 | from configurator import Configuration |
9 | 47 | from gcal import GCal | 47 | from googlecalendar import GoogleCalendar |
10 | 48 | from preferences_dialog import Preferences | 48 | from preferences_dialog import Preferences |
11 | 49 | # | 49 | # |
12 | 50 | locale.setlocale(locale.LC_ALL, '') | 50 | locale.setlocale(locale.LC_ALL, '') |
13 | @@ -52,29 +52,9 @@ | |||
14 | 52 | gettext.textdomain(comun.APP) | 52 | gettext.textdomain(comun.APP) |
15 | 53 | _ = gettext.gettext | 53 | _ = gettext.gettext |
16 | 54 | 54 | ||
17 | 55 | def internet_on(): | ||
18 | 56 | try: | ||
19 | 57 | response=urllib2.urlopen('http://google.com',timeout=1) | ||
20 | 58 | return True | ||
21 | 59 | except: | ||
22 | 60 | pass | ||
23 | 61 | return False | ||
24 | 62 | |||
25 | 63 | |||
26 | 64 | def getTimeAndDate(cadena): | ||
27 | 65 | if cadena.find('T')==-1: | ||
28 | 66 | date = cadena.split('-') | ||
29 | 67 | time = datetime.time(0,0,0) | ||
30 | 68 | else: | ||
31 | 69 | date = cadena.split('T')[0].split('-') | ||
32 | 70 | time = cadena.split('T')[1].split(':') | ||
33 | 71 | time = datetime.time(int(time[0]),int(time[1]),int(time[2][0:2])) | ||
34 | 72 | date = datetime.date(int(date[0]),int(date[1]),int(date[2])) | ||
35 | 73 | return date.strftime('%d/%m/%Y')+' - '+time.strftime('%H:%M') | ||
36 | 74 | |||
37 | 75 | def check_events(event1,event2): | 55 | def check_events(event1,event2): |
40 | 76 | if event1.when[0].start == event2.when[0].start: | 56 | if event1.when[0].start_time == event2.when[0].start_time: |
41 | 77 | if event1.when[0].end == event2.when[0].end: | 57 | if event1.when[0].end_time == event2.when[0].end_time: |
42 | 78 | if event1.title.text == event2.title.text: | 58 | if event1.title.text == event2.title.text: |
43 | 79 | return True | 59 | return True |
44 | 80 | return False | 60 | return False |
45 | @@ -119,6 +99,8 @@ | |||
46 | 119 | self.read_preferences() | 99 | self.read_preferences() |
47 | 120 | # | 100 | # |
48 | 121 | self.events = [] | 101 | self.events = [] |
49 | 102 | self.load_events() | ||
50 | 103 | self.set_icon() | ||
51 | 122 | self.set_menu() | 104 | self.set_menu() |
52 | 123 | GObject.timeout_add_seconds(60, self.work) | 105 | GObject.timeout_add_seconds(60, self.work) |
53 | 124 | 106 | ||
54 | @@ -127,7 +109,7 @@ | |||
55 | 127 | while error: | 109 | while error: |
56 | 128 | try: | 110 | try: |
57 | 129 | configuration = Configuration() | 111 | configuration = Configuration() |
59 | 130 | self.gcal=GCal(configuration.get('user'), configuration.get('password')) | 112 | self.gcal = GoogleCalendar(configuration.get('user'), configuration.get('password')) |
60 | 131 | self.time = configuration.get('time') | 113 | self.time = configuration.get('time') |
61 | 132 | self.theme = configuration.get('theme') | 114 | self.theme = configuration.get('theme') |
62 | 133 | error = False | 115 | error = False |
63 | @@ -153,45 +135,53 @@ | |||
64 | 153 | 135 | ||
65 | 154 | def work(self): | 136 | def work(self): |
66 | 155 | if (time.time()-self.actualization_time) > self.time*60: | 137 | if (time.time()-self.actualization_time) > self.time*60: |
71 | 156 | while internet_on() == False: | 138 | try: |
72 | 157 | time.sleep(1) | 139 | self.load_events(True) |
73 | 158 | self.actualization_time = time.time() | 140 | except Exception, e: |
74 | 159 | self.set_menu(check=True) | 141 | print e |
75 | 142 | return True | ||
76 | 143 | self.set_icon() | ||
77 | 144 | self.set_menu() | ||
78 | 160 | return True | 145 | return True |
79 | 161 | 146 | ||
82 | 162 | def set_menu(self,check=False): | 147 | def load_events(self,check=False): |
83 | 163 | # | 148 | new_events = self.gcal.AgendaQuery() |
84 | 149 | |||
85 | 150 | if check: | ||
86 | 151 | for event in new_events: | ||
87 | 152 | if not is_event_in_events(event, self.events): | ||
88 | 153 | msg = event.s.strftime('%d/%m/%Y - %H:%M') + ' - ' + event.title.text | ||
89 | 154 | self.notification = Notify.Notification.new(_('New event:'), msg, comun.ICON_NEW_EVENT) | ||
90 | 155 | self.notification.show() | ||
91 | 156 | for event in self.events: | ||
92 | 157 | if not is_event_in_events(event, new_events): | ||
93 | 158 | msg = event.s.strftime('%d/%m/%Y - %H:%M') + ' - ' + event.title.text | ||
94 | 159 | self.notification = Notify.Notification.new(_('Event finished:'), msg, comun.ICON_FINISHED_EVENT) | ||
95 | 160 | self.notification.show() | ||
96 | 161 | |||
97 | 162 | self.events = new_events | ||
98 | 163 | self.actualization_time = time.time() | ||
99 | 164 | |||
100 | 165 | def set_icon(self): | ||
101 | 164 | now = datetime.datetime.now() | 166 | now = datetime.datetime.now() |
104 | 165 | normal_icon = os.path.join(comun.ICONDIR,'%s-%s-normal.svg'%(now.day,self.theme)) | 167 | normal_icon = os.path.join(comun.ICONDIR, '%s-%s-normal.svg' % (now.day, self.theme)) |
105 | 166 | starred_icon = os.path.join(comun.ICONDIR,'%s-%s-starred.svg'%(now.day,self.theme)) | 168 | starred_icon = os.path.join(comun.ICONDIR, '%s-%s-starred.svg' % (now.day, self.theme)) |
106 | 167 | # | 169 | # |
107 | 168 | self.indicator.set_icon(normal_icon) | 170 | self.indicator.set_icon(normal_icon) |
108 | 169 | self.indicator.set_attention_icon(starred_icon) | 171 | self.indicator.set_attention_icon(starred_icon) |
109 | 170 | #self.indicator.set_icon(comun.ICON_ENABLED) | 172 | #self.indicator.set_icon(comun.ICON_ENABLED) |
112 | 171 | #self.indicator.set_attention_icon(comun.ICON_DISABLED) | 173 | #self.indicator.set_attention_icon(comun.ICON_DISABLED) |
113 | 172 | # | 174 | |
114 | 175 | if self._has_today(now): | ||
115 | 176 | self.indicator.set_status(appindicator.IndicatorStatus.ATTENTION) | ||
116 | 177 | else: | ||
117 | 178 | self.indicator.set_status(appindicator.IndicatorStatus.ACTIVE) | ||
118 | 179 | |||
119 | 180 | def set_menu(self): | ||
120 | 173 | self.menu = Gtk.Menu() | 181 | self.menu = Gtk.Menu() |
121 | 174 | # | 182 | # |
122 | 175 | events2 = self.gcal.getFirstTenEventsOnDefaultCalendar() | ||
123 | 176 | if check and len(self.events)>0: | ||
124 | 177 | for event in events2: | ||
125 | 178 | if not is_event_in_events(event,self.events): | ||
126 | 179 | msg = _('New event:')+'\n' | ||
127 | 180 | msg += getTimeAndDate(event.when[0].start)+' - '+event.title.text | ||
128 | 181 | print msg | ||
129 | 182 | self.notification = Notify.Notification ('Calendar Indicator',msg,comun.ICON_NEW_EVENT) | ||
130 | 183 | self.notification.show() | ||
131 | 184 | for event in self.events: | ||
132 | 185 | if not is_event_in_events(event,events2): | ||
133 | 186 | msg = _('Event finished:')+'\n' | ||
134 | 187 | msg += getTimeAndDate(event.when[0].start)+' - '+event.title.text | ||
135 | 188 | print msg | ||
136 | 189 | self.notification = Notify.Notification ('Calendar Indicator',msg,comun.ICON_FINISHED_EVENT) | ||
137 | 190 | self.notification.show() | ||
138 | 191 | |||
139 | 192 | self.events = events2 | ||
140 | 193 | for event in self.events: | 183 | for event in self.events: |
142 | 194 | add2menu(self.menu, text = (getTimeAndDate(event.when[0].start)+' - '+event.title.text)) | 184 | add2menu(self.menu, text = (event.s.strftime('%d/%m/%Y - %H:%M') + ' - ' + event.title.text)) |
143 | 195 | # | 185 | # |
144 | 196 | add2menu(self.menu) | 186 | add2menu(self.menu) |
145 | 197 | self.menu_show_calendar = add2menu(self.menu, text = _('Show Calendar'), conector_event = 'activate',conector_action = self.menu_show_calendar_response) | 187 | self.menu_show_calendar = add2menu(self.menu, text = _('Show Calendar'), conector_event = 'activate',conector_action = self.menu_show_calendar_response) |
146 | @@ -202,29 +192,11 @@ | |||
147 | 202 | add2menu(self.menu) | 192 | add2menu(self.menu) |
148 | 203 | add2menu(self.menu, text = _('Exit'), conector_event = 'activate',conector_action = self.menu_exit_response) | 193 | add2menu(self.menu, text = _('Exit'), conector_event = 'activate',conector_action = self.menu_exit_response) |
149 | 204 | # | 194 | # |
150 | 205 | now = datetime.datetime.now() | ||
151 | 206 | if self.events[0].when[0].start.find('T') != -1: | ||
152 | 207 | print self.events[0].when[0].start | ||
153 | 208 | if self.events[0].when[0].start.find('.') != -1: | ||
154 | 209 | com = datetime.datetime.strptime(self.events[0].when[0].start.split('.')[0],'%Y-%m-%dT%H:%M:%S') | ||
155 | 210 | else: | ||
156 | 211 | com = datetime.datetime.strptime(self.events[0].when[0].start,'%Y-%m-%dT%H:%M:%S') | ||
157 | 212 | |||
158 | 213 | else: | ||
159 | 214 | com = datetime.datetime.strptime(self.events[0].when[0].start,'%Y-%m-%d') | ||
160 | 215 | if now.year == com.year and now.month == com.month and now.day == com.day and now.hour == com.hour: | ||
161 | 216 | self.indicator.set_status (appindicator.IndicatorStatus.ATTENTION) | ||
162 | 217 | else: | ||
163 | 218 | print now.hour | ||
164 | 219 | print com.hour | ||
165 | 220 | print self.events[0].when[0].start | ||
166 | 221 | self.indicator.set_status (appindicator.IndicatorStatus.ACTIVE) | ||
167 | 222 | # | ||
168 | 223 | self.menu.show() | 195 | self.menu.show() |
169 | 224 | self.indicator.set_menu(self.menu) | 196 | self.indicator.set_menu(self.menu) |
170 | 197 | # | ||
171 | 225 | while Gtk.events_pending(): | 198 | while Gtk.events_pending(): |
172 | 226 | Gtk.main_iteration() | 199 | Gtk.main_iteration() |
173 | 227 | |||
174 | 228 | 200 | ||
175 | 229 | def get_help_menu(self): | 201 | def get_help_menu(self): |
176 | 230 | help_menu =Gtk.Menu() | 202 | help_menu =Gtk.Menu() |
177 | @@ -250,7 +222,7 @@ | |||
178 | 250 | while error: | 222 | while error: |
179 | 251 | try: | 223 | try: |
180 | 252 | configuration = Configuration() | 224 | configuration = Configuration() |
182 | 253 | self.gcal=GCal(configuration.get('user'), configuration.get('password')) | 225 | self.gcal=GoogleCalendar(configuration.get('user'), configuration.get('password')) |
183 | 254 | self.time = configuration.get('time') | 226 | self.time = configuration.get('time') |
184 | 255 | self.theme = configuration.get('theme') | 227 | self.theme = configuration.get('theme') |
185 | 256 | error = False | 228 | error = False |
186 | @@ -311,6 +283,12 @@ | |||
187 | 311 | ad.run() | 283 | ad.run() |
188 | 312 | ad.destroy() | 284 | ad.destroy() |
189 | 313 | self.menu_about.set_sensitive(True) | 285 | self.menu_about.set_sensitive(True) |
190 | 286 | |||
191 | 287 | def _has_today(self, today): | ||
192 | 288 | for event in self.events: | ||
193 | 289 | if today.year == event.s.year and today.month == event.s.month and today.day == event.s.day and today.hour == event.s.hour: | ||
194 | 290 | return True | ||
195 | 291 | return False | ||
196 | 314 | 292 | ||
197 | 315 | if __name__ == "__main__": | 293 | if __name__ == "__main__": |
198 | 316 | Notify.init("calendar-indicator") | 294 | Notify.init("calendar-indicator") |
199 | 317 | 295 | ||
200 | === modified file 'src/comun.py' | |||
201 | --- src/comun.py 2012-02-19 20:33:42 +0000 | |||
202 | +++ src/comun.py 2012-03-01 20:44:18 +0000 | |||
203 | @@ -60,5 +60,5 @@ | |||
204 | 60 | APPDIR = os.path.join(ROOTDIR, APP) | 60 | APPDIR = os.path.join(ROOTDIR, APP) |
205 | 61 | ICONDIR = os.path.join(ROOTDIR, 'data/icons') | 61 | ICONDIR = os.path.join(ROOTDIR, 'data/icons') |
206 | 62 | 62 | ||
209 | 63 | ICON_NEW_EVENT = 'event-new' | 63 | ICON_NEW_EVENT = os.path.join(ICONDIR, 'event-new.svg') |
210 | 64 | ICON_FINISHED_EVENT = 'event-finished' | 64 | ICON_FINISHED_EVENT = os.path.join(ICONDIR, 'event-finished.svg') |
211 | 65 | 65 | ||
212 | === added file 'src/googlecalendar.py' | |||
213 | --- src/googlecalendar.py 1970-01-01 00:00:00 +0000 | |||
214 | +++ src/googlecalendar.py 2012-03-01 20:44:18 +0000 | |||
215 | @@ -0,0 +1,190 @@ | |||
216 | 1 | #! /usr/bin/python | ||
217 | 2 | # -*- coding: iso-8859-15 -*- | ||
218 | 3 | # | ||
219 | 4 | __author__='atareao' | ||
220 | 5 | __date__ ='$30/10/2010' | ||
221 | 6 | # | ||
222 | 7 | # Copyright (C) 2010 Lorenzo Carbonell | ||
223 | 8 | # lorenzo.carbonell.cerezo@gmail.com | ||
224 | 9 | # | ||
225 | 10 | # This program is free software: you can redistribute it and/or modify | ||
226 | 11 | # it under the terms of the GNU General Public License as published by | ||
227 | 12 | # the Free Software Foundation, either version 3 of the License, or | ||
228 | 13 | # (at your option) any later version. | ||
229 | 14 | # | ||
230 | 15 | # This program is distributed in the hope that it will be useful, | ||
231 | 16 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
232 | 17 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
233 | 18 | # GNU General Public License for more details. | ||
234 | 19 | # | ||
235 | 20 | # You should have received a copy of the GNU General Public License | ||
236 | 21 | # along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
237 | 22 | # | ||
238 | 23 | import sys, re, urllib, getopt | ||
239 | 24 | import threading, getpass | ||
240 | 25 | from Queue import Queue | ||
241 | 26 | from gdata.calendar.service import * | ||
242 | 27 | from datetime import * | ||
243 | 28 | from dateutil.tz import * | ||
244 | 29 | from dateutil.parser import * | ||
245 | 30 | |||
246 | 31 | class GoogleCalendar(object): | ||
247 | 32 | allCals = None | ||
248 | 33 | cals = [] | ||
249 | 34 | now = datetime.now(tzlocal()) | ||
250 | 35 | agendaLength = 30 | ||
251 | 36 | |||
252 | 37 | def __init__(self,email,password): | ||
253 | 38 | self.email = email | ||
254 | 39 | self.password = password | ||
255 | 40 | self.client = CalendarService() | ||
256 | 41 | self.client.ClientLogin(self.email,self.password, 'calendar-indicator') | ||
257 | 42 | |||
258 | 43 | # get the list of calendars | ||
259 | 44 | self.allCals = self.client.GetAllCalendarsFeed() | ||
260 | 45 | for cal in self.allCals.entry: | ||
261 | 46 | cal.gcalcli_altLink = cal.GetAlternateLink().href | ||
262 | 47 | match = re.match('^https?://www.google.com/calendar/feeds/(.*?)/(.*?)/(.*)$', cal.gcalcli_altLink) | ||
263 | 48 | cal.gcalcli_username = urllib.unquote(match.group(1)) | ||
264 | 49 | cal.gcalcli_visibility = urllib.unquote(match.group(2)) | ||
265 | 50 | cal.gcalcli_projection = urllib.unquote(match.group(3)) | ||
266 | 51 | self.cals.append(cal) | ||
267 | 52 | |||
268 | 53 | def AgendaQuery(self): | ||
269 | 54 | start = self.now | ||
270 | 55 | end = (start + timedelta(days=self.agendaLength)) | ||
271 | 56 | return self._SearchForCalEvents(start, end, None) | ||
272 | 57 | |||
273 | 58 | def _SearchForCalEvents(self, start, end, searchText): | ||
274 | 59 | eventList = [] | ||
275 | 60 | queue = Queue() | ||
276 | 61 | threads = [] | ||
277 | 62 | |||
278 | 63 | def worker(cal, query): | ||
279 | 64 | feed = self.client.CalendarQuery(query) | ||
280 | 65 | queue.put((cal, feed)) | ||
281 | 66 | |||
282 | 67 | for cal in self.cals: | ||
283 | 68 | # see http://code.google.com/apis/calendar/reference.html | ||
284 | 69 | if not searchText: | ||
285 | 70 | query = CalendarEventQuery(cal.gcalcli_username, cal.gcalcli_visibility, cal.gcalcli_projection) | ||
286 | 71 | query.start_min = start.isoformat() | ||
287 | 72 | query.start_max = end.isoformat() | ||
288 | 73 | else: | ||
289 | 74 | query = CalendarEventQuery(cal.gcalcli_username, cal.gcalcli_visibility, cal.gcalcli_projection, searchText) | ||
290 | 75 | if start: # flagged by --ignore-started | ||
291 | 76 | # weeds out old but still pulls in started events | ||
292 | 77 | query.futureevents = 'true' | ||
293 | 78 | |||
294 | 79 | query.singleevents = 'true' | ||
295 | 80 | |||
296 | 81 | # we sort later after getting events from all calendars | ||
297 | 82 | #query.orderby = 'starttime' | ||
298 | 83 | #query.sortorder = 'ascending' | ||
299 | 84 | |||
300 | 85 | th = threading.Thread(target=worker, args=(cal, query)) | ||
301 | 86 | threads.append(th) | ||
302 | 87 | th.start() | ||
303 | 88 | |||
304 | 89 | for th in threads: | ||
305 | 90 | th.join() | ||
306 | 91 | |||
307 | 92 | while not queue.empty(): | ||
308 | 93 | cal, feed = queue.get() | ||
309 | 94 | eventList.extend(self._GetAllEvents(cal, feed, end)) | ||
310 | 95 | |||
311 | 96 | eventList.sort(lambda x, y: cmp(x.s, y.s)) | ||
312 | 97 | |||
313 | 98 | return eventList | ||
314 | 99 | |||
315 | 100 | def _GetAllEvents(self, cal, feed, end): | ||
316 | 101 | eventList = [] | ||
317 | 102 | |||
318 | 103 | while 1: | ||
319 | 104 | next = feed.GetNextLink() | ||
320 | 105 | |||
321 | 106 | for event in feed.entry: | ||
322 | 107 | event.gcalcli_cal = cal | ||
323 | 108 | |||
324 | 109 | event.s = parse(event.when[0].start_time) | ||
325 | 110 | if event.s.tzinfo == None: | ||
326 | 111 | event.s = event.s.replace(tzinfo=tzlocal()) | ||
327 | 112 | |||
328 | 113 | event.e = parse(event.when[0].end_time) | ||
329 | 114 | if event.e.tzinfo == None: | ||
330 | 115 | event.e = event.e.replace(tzinfo=tzlocal()) | ||
331 | 116 | |||
332 | 117 | # For all-day events, Google seems to assume that the event time | ||
333 | 118 | # is based in the UTC instead of the local timezone. Here we | ||
334 | 119 | # filter out those events start beyond a specified end time. | ||
335 | 120 | if end and (event.s >= end): | ||
336 | 121 | continue | ||
337 | 122 | |||
338 | 123 | # http://en.wikipedia.org/wiki/Year_2038_problem | ||
339 | 124 | # Catch the year 2038 problem here as the python dateutil module | ||
340 | 125 | # can choke throwing a ValueError exception. If either the start | ||
341 | 126 | # or end time for an event has a year '>= 2038' dump it. | ||
342 | 127 | if event.s.year >= 2038 or event.e.year >= 2039: | ||
343 | 128 | continue | ||
344 | 129 | |||
345 | 130 | eventList.append(event) | ||
346 | 131 | |||
347 | 132 | if not next: | ||
348 | 133 | break | ||
349 | 134 | |||
350 | 135 | feed = self.client.GetCalendarEventFeed(next.href) | ||
351 | 136 | |||
352 | 137 | return eventList | ||
353 | 138 | |||
354 | 139 | def _ValidTitle(self, title): | ||
355 | 140 | if title == None: | ||
356 | 141 | return "(No title)" | ||
357 | 142 | else: | ||
358 | 143 | return title | ||
359 | 144 | |||
360 | 145 | def _CalendarColor(self, cal): | ||
361 | 146 | if cal != None and hasattr(cal, 'colorSpec') and cal.colorSpec != None: | ||
362 | 147 | return cal.colorSpec | ||
363 | 148 | else: | ||
364 | 149 | return None | ||
365 | 150 | |||
366 | 151 | if __name__ == '__main__': | ||
367 | 152 | try: | ||
368 | 153 | opts, args = getopt.getopt(sys.argv[1:], "", [ "user=","pw=" ]) | ||
369 | 154 | except getopt.error: | ||
370 | 155 | sys.exit(1) | ||
371 | 156 | |||
372 | 157 | usr = None | ||
373 | 158 | pwd = None | ||
374 | 159 | |||
375 | 160 | for opt, arg in opts: | ||
376 | 161 | if opt == "--user": | ||
377 | 162 | usr = arg | ||
378 | 163 | elif opt == "--pw": | ||
379 | 164 | pwd = arg | ||
380 | 165 | |||
381 | 166 | if usr == None: | ||
382 | 167 | sys.stdout.write('Error: must specify a username\n') | ||
383 | 168 | sys.exit(1) | ||
384 | 169 | |||
385 | 170 | try: | ||
386 | 171 | if pwd == None: | ||
387 | 172 | pwd = getpass.getpass("Password: ") | ||
388 | 173 | except Exception, e: | ||
389 | 174 | sys.stdout.write("Error: " + str(e) + "!\n") | ||
390 | 175 | sys.exit(1) | ||
391 | 176 | |||
392 | 177 | if pwd == None or pwd == '': | ||
393 | 178 | sys.stdout.write('Error: must specify a password\n') | ||
394 | 179 | sys.exit(1) | ||
395 | 180 | |||
396 | 181 | try: | ||
397 | 182 | gcal = GoogleCalendar(usr, pwd) | ||
398 | 183 | except Exception, e: | ||
399 | 184 | sys.stdout.write("Error: " + str(e) + "!\n") | ||
400 | 185 | sys.exit(1) | ||
401 | 186 | |||
402 | 187 | for event in gcal.AgendaQuery(): | ||
403 | 188 | print event.title.text | ||
404 | 189 | |||
405 | 190 | sys.exit(0) |