0

I would like to use CalDAV python module to get the whole information from an event, I managed to get a link for the event, but I do not understand how to get the event detail from that event, so I have the link to the event:

https://mail.example.com:443/public-calendars/example.com/9A0F7585-A952-4E0C-868C-0C072A2D8740/9a0f7585-a952-4e0c-868c-0c072a2d8740-0000048a.eml

And I am trying this to get the event details:

event = 'https://mail.example.com:443/public-calendars/example.com/9A0F7585-A952-4E0C-868C-0C072A2D8740/9a0f7585-a952-4e0c-868c-0c072a2d8740-0000048a.eml'
eventDetail = caldav.Event(event).load()

But I am getting the error:

AttributeError: 'str' object has no attribute 'request'

What I would like to get is something like this:

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

I would like to put that into a variable, so that I can go through that information and search for what I need or send it to a file.

dsturlan
  • 1
  • 3

2 Answers2

0

Looking at the modules caldav/objects.py I see:

def __init__(self, client=None, url=None, data=None, parent=None, id=None)

You are passing in the URL as the client object (1st parameter), hence the error.

Maybe this would work, but probably not (to load, it quite likely needs a client object):

eventDetail = caldav.Event(url=event).load()

But looking further down the module I see an event_by_url on the calendar object:

class Calendar(DAVObject):
  ...
  def event_by_url(self, href, data=None):

Presumably you already have access to the calendar objects, so I suppose it may be a simple:

event = calendar.event_by_url("/calendars/123.ics")
hnh
  • 13,957
  • 6
  • 30
  • 40
0

Take the event url and try something like:

event_url = 'https://mail.example.com:443/public-calendars/example.com/9A0F7585-A952-4E0C-868C-0C072A2D8740/9a0f7585-a952-4e0c-868c-0c072a2d8740-0000048a.eml'
eventl = calendar.event_by_url(event_url)

Then you can load data into an object "<class 'vobject.icalendar.RecurringComponent'>" like this:

event_data = eventl.vobject_instance.vevent

And, for example, access "SUMMARY" like this:

event_summary = eventl.vobject_instance.vevent.summary.value
Tomerikoo
  • 18,379
  • 16
  • 47
  • 61