Dears,
Due some issue on GCalendar, one of my users had a multiplication on his
events.
The issue is, I have to delete 3000 events running a script, but I'me
getting a error.
I'me using updated version of google library and Python 2.6.
Bellow, the script and the error that I'm getting.
Could you please advise?
*SCRIPT*
----------------------------------------------------
import gdata.calendar.service
import gdata.service
import gdata.calendar
# The function we'll use to delete the relevant calendar entries
def DeleteEventEntries(calendar_service, calendar='default',
start_date='2010-01-01', end_date='2010-12-31', pattern="", delete=False):
print 'Date range query for events on %s Calendar: %s to %s' % (calendar,
start_date, end_date,)
query = gdata.calendar.service.CalendarEventQuery(calendar, 'private',
'full', pattern)
query.start_min = start_date
query.start_max = end_date
query['max-results'] = '25'
feed = calendar_service.CalendarQuery(query)
total_results = feed.total_results.text.strip()
print "Total results: %s" % (total_results,)
i = 1
while True:
for an_event in feed.entry:
print '\t%s/%s. %s (%s)' % (i, total_results,
an_event.title.text,an_event.id.text.strip(),)
i += 1
if delete:
print '\t -> Deleting entry (%s)' % (an_event.GetEditLink().href,)
calendar_service.DeleteEvent(an_event.GetEditLink().href)
if feed.GetNextLink():
feed =
calendar_service.Query(feed.GetNextLink().href,converter=gdata.calendar.CalendarEventFeedFromString)
else:
print 'Done'
break;
calendar_service = gdata.calendar.service.CalendarService()
calendar_service.email = '[email protected]' # Email Address
calendar_service.password = 'password' # Please insert your password here
calendar_service.source = 'Event-Deletion-1.0'
calendar_service.ProgrammaticLogin()
# TEST SECTION: When the option below is active, it only lists the events
that will be deleted. Run this first and see what kind of results you get.
#DeleteEventEntries(calendar_service=calendar_service,
calendar='[email protected]', start_date='2011-09-21',
end_date='2011-09-23', pattern='Frank Richter');
# DELETE SECTION: Uncomment the option below and add a commenting mark (#)
to the line above when ready to delete events. This option cannot be undone
- run at your own risk.
DeleteEventEntries(calendar_service=calendar_service,
calendar='[email protected]', start_date='2011-09-21',
end_date='2011-09-23', pattern='Frank Richter', delete=True);
---------------------------------------------------------------------------------
ERROR
-------------------------------------------------------------------------------
C:\Python26>python.exe caleventremoverfinal.py
Date range query for events on [email protected] Calendar:
2011-09-21
to 2011-09-23
Total results: 3121
1/3121. Frank Richter
(http://www.google.com/calendar/feeds/joerg.spiege
l%40converteam.com/private/full/_68o32c1g6op3el1h60qjgc9o5lh78prdf1pmuqpd6so48d2
16923ec9o6t1k2e9k6h1j2chl6sr36hhg60qj2cpk6grk0orfdpr6asjkclgmqbj3dtmg_20110922)
-> Deleting entry
(https://www.google.com/calendar/feeds/joerg.spiegel%
40converteam.com/private/full/_68o32c1g6op3el1h60qjgc9o5lh78prdf1pmuqpd6so48d216
923ec9o6t1k2e9k6h1j2chl6sr36hhg60qj2cpk6grk0orfdpr6asjkclgmqbj3dtmg_20110922/634
32915224)
Traceback (most recent call last):
File "caleventremoverfinal.py", line 39, in <module>
DeleteEventEntries(calendar_service=calendar_service,
calendar='joerg.spiege
[email protected]', start_date='2011-09-21', end_date='2011-09-23',
pattern='Fran
k Richter', delete=True);
File "caleventremoverfinal.py", line 22, in DeleteEventEntries
calendar_service.DeleteEvent(an_event.GetEditLink().href)
File "C:\Python26\lib\gdata\calendar\service.py", line 314, in DeleteEvent
url_params=url_params, escape_params=escape_params)
File "C:\Python26\lib\gdata\service.py", line 1455, in Delete
'reason': server_response.reason, 'body': result_body}
gdata.service.RequestError: {'status': 404, 'body': 'No events found',
'reason':
'Not Found'}
--
You received this message because you are subscribed to the Google
Groups "Google Calendar Data API" group.
To post to this group, send email to
[email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://code.google.com/apis/calendar/community/forum.html