开发者

How to access Apples iCal-Server via Python

开发者 https://www.devze.com 2023-01-17 10:37 出处:网络
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.

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 Ca开发者_如何学GolDav-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?


[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):
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号