如何通过Python访问Apple的iCal-Server

发布于 2024-09-20 00:40:29 字数 363 浏览 10 评论 0原文

我正在尝试通过 Python 访问 Mac OS X Snow Leopard 服务器上的 Apple iCal-Server。服务器已启动并正在运行,并且可以通过 iCal 应用程序使用它。 现在我需要通过Python访问该服务器,将其用作资源规划的后端。我已经看过 CalDav-Module (http://packages.python.org/caldav/ index.html),但那里提供的示例没有找到任何日历,尽管主体 URL 是正确的。

那么如何使用 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?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

浮萍、无处依 2024-09-27 00:40:29

[不是解决方案,而是调试]

来自 caldav 模块文档中给出的示例:

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()

问题

  1. 则 url 示例不是 ical 服务器的主要 url
  2. 如果您查看代码, 对于 calendars =principal.calendars(),它忽略响应。
  3. 如果您的主网址不正确,则不会发出任何错误,它将仅返回一组空日历。

调试帮助

在文件objects.py中,有一个DAVObject的方法,称为children。您可以修改代码以包含一些调试信息。如果您可以粘贴以下内容,并将您的信息粘贴到问题中。

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

[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):
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文