Add calendar event using python/caldav

3k views Asked by At

I use python/caldav and python/icalendar to add a calendar event to my caldav-calendar.

Reading events and calendars works without problems.

Now i take an event from an ics file and try to add it to my caldav-calendar.

meetings = icalendar.Calendar.from_ical(ics-file)
for event in meetings.walk():
    if event.name == "VEVENT":
        ical = event.to_ical()
        print(ical)
        my_caldav_calendar.add_event(ical)

However, this leads me to the following error:

Traceback (most recent call last):
File "vss_filter.py", line 45, in <module>
  my_caldav_calendar.add_event(ical)
File "/usr/local/lib/python2.7/site-packages/caldav/objects.py", line 422, in add_event
  return Event(self.client, data = ical, parent = self).save()
File "/usr/local/lib/python2.7/site-packages/caldav/objects.py", line 718, in save
  self._create(self._instance.serialize(), self.id, path)
File "/usr/local/lib/python2.7/site-packages/caldav/objects.py", line 696, in _create
  path = id + ".ics"
TypeError: unsupported operand type(s) for +: 'NoneType' and 'str'

The ical-event clearly has a field 'UID', as the print shows:

BEGIN:VEVENT
SUMMARY:event-title
DTSTART;TZID=Europe/Warsaw:20150305T130000
DTEND;TZID=Europe/Warsaw:20150305T140000
DTSTAMP:20150624T170317Z
UID:9149F870-5475-4120-9EE5-1A06E857807B
SEQUENCE:1
EXDATE;TZID=Europe/Warsaw:20150618T130000
EXDATE;TZID=Europe/Warsaw:20150305T130000
EXDATE;TZID=Europe/Warsaw:20150430T130000
CREATED:20150226T105018Z
DESCRIPTION:
LAST-MODIFIED:20150616T094907Z
LOCATION:
RRULE:FREQ=WEEKLY;UNTIL=20150624T235959Z;INTERVAL=1
STATUS:CONFIRMED
TRANSP:OPAQUE
BEGIN:VALARM
ACTION:NONE
TRIGGER;VALUE=DATE-TIME:19760401T005545Z
UID:FC67F59E-5540-47BE-ACFA-FE229771EC11
X-WR-ALARMUID:FC67F59E-5540-47BE-ACFA-FE229771EC11
END:VALARM
END:VEVENT

so there should be an id python/caldav can find. Why is this failing an dhow can i fix it?

0

There are 0 answers