无法将日历事件保存到Darwin Calendar服务器

时间:2014-04-08 14:33:30

标签: python darwin caldav

我正在尝试使用日历服务器,并选择了Darwin的开源日历服务器作为服务器。我已按照Quick start页面中提到的步骤操作,我可以让服务器运行。

然后我编写了以下python脚本来保存日历事件

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

# Caldav url
url = "http://apprentice:apprentice@localhost:8008/calendars/users/apprentice/calendar/"

vcal = """BEGIN:VCALENDAR
VERSION:2.0
PRODID:-//Example Corp.//CalDAV Client//EN
BEGIN:VEVENT
UID:1234567890
DTSTAMP:20100510T182145Z
DTSTART:20100512T170000Z
DTEND:20100512T180000Z
SUMMARY:This is an event
END:VEVENT
END:VCALENDAR
"""

client = caldav.DAVClient(url)
principal = caldav.Principal(client)
calendars = principal.calendars()
if len(calendars) > 0:
    calendar = calendars[0]
    print "Using calendar", calendar

    print "Renaming"
    calendar.set_properties([dav.DisplayName("Test calendar"),])
    print calendar.get_properties([dav.DisplayName(),])

    event = calendar.add_event(vcal)
    print "Event", event, "created"

    print "Looking for events in 2010-05"
    results = calendar.date_search(
        datetime(2010, 5, 1), datetime(2010, 6, 1))

    for event in results:
        print "Found", event

我收到以下错误

  

文件“nodesets.py”,第22行,in       principal = caldav.Principal(client)文件“/Library/Python/2.7/site-packages/caldav/objects.py”,第256行,in   的初始化       cup = self.get_properties([dav.CurrentUserPrincipal()])文件“/Library/Python/2.7/site-packages/caldav/objects.py”,第151行,in   get_properties       提升异常(“您正在使用的CalDAV服务器具有”例外:您正在使用的CalDAV服务器存在路径处理问题。

知道我做错了吗?

由于

1 个答案:

答案 0 :(得分:0)

我会先尝试

url = "http://apprentice:apprentice@localhost:8008/"