Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to access Apples iCal-Server via Python

I'm trying to access Apples iCal-Server on a Mac OS X Snow Leopard Server via Python. The server is up and running and working with it via the iCal-Application is just fine. Now I need to access this server via Python to use it as backend for resource planning. I have already looked at the CalDav-Module (http://packages.python.org/caldav/index.html) but the sample provided there didn't find any calendar, although the Principal-URL is correct.

So how can I read the events within a time range from a user's calendar using python?

like image 936
Hive Avatar asked Jun 14 '26 13:06

Hive


1 Answers

[Not a solution but to debug]

From the example given in the caldav module documentation:

from datetime import datetime
import caldav
from caldav.elements import dav, cdav

# Principal url
url = "https://user:pass@hostname/user/Calendar"

client = caldav.DAVClient(url)
principal = caldav.Principal(client, url)
calendars = principal.calendars()

Issues

  1. The url example is not the principal url for ical server
  2. if you look at the code for calendars = principal.calendars(), it ignores the response.
  3. If your principal url is incorrect then without issuing any errors it will return just an empty set of calendars.

Debugging help:

in file objects.py, there is a method for DAVObject called children. You can modify the code to include some debugging information. If you can paste the following and also paste your information in the question.

    response = self.client.propfind(self.url.path, body, depth)
    print response, self.url.path #provide additional info
    print response.raw  #provide additional info
    for r in response.tree.findall(dav.Response.tag):
like image 170
pyfunc Avatar answered Jun 16 '26 02:06

pyfunc



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!