在 Raspberry Pi 上通过 caldav 使用 python 读取 owncloud 日历
read owncloud calendar using python via caldav on Raspberry Pi
概览
我的目标是在 Raspberry Pi 上开发一个 Python 应用程序 运行,它通过网络读取 OwnCloud 日历条目。日历本身是 Owncloud 本地安装的一部分,它位于同一本地网络中的另一个 Raspberry Pi 上。进行请求时,访问是通过 HTTPS 完成的,无需主动 SSL 身份验证。
问题
我尝试使用 caldav Python 包。使用 PIP 和 Python v2.7 安装包后,我得到一个 Exception: The CalDAV server you are using has a problem with path handling.
这是我在 PYTHON IDLE v2.7 中输入的内容:
import caldav
cal_user='user'
cal_pass='pass'
cal_url='https://192.168.1.46/remote.php/caldav/calendars/user/pers%C3%B6nlich'
cal_client=caldav.DAVClient(cal_url, username='user', password='pass', ssl_verify_cert=False)
cal_principal=cal_client.principal()
这是控制台上打印的内容:
Warning (from warnings module):
File "C:\PROGS\Python27\lib\site-packages\requests\packages\urllib3\connectionpool.py", line 789
InsecureRequestWarning)
InsecureRequestWarning: Unverified HTTPS request is being made. Adding certificate verification is strongly advised. See: https://urllib3.readthedocs.org/en/latest/security.html
Warning (from warnings module):
File "C:\PROGS\Python27\lib\site-packages\requests\packages\urllib3\connectionpool.py", line 789
InsecureRequestWarning)
InsecureRequestWarning: Unverified HTTPS request is being made. Adding certificate verification is strongly advised. See: https://urllib3.readthedocs.org/en/latest/security.html
Traceback (most recent call last):
File "<pyshell#9>", line 1, in <module>
cal_principal=cal_client.principal()
File "C:\PROGS\Python27\lib\site-packages\caldav\davclient.py", line 113, in principal
return Principal(self)
File "C:\PROGS\Python27\lib\site-packages\caldav\objects.py", line 307, in __init__
cup = self.get_properties([dav.CurrentUserPrincipal()])
File "C:\PROGS\Python27\lib\site-packages\caldav\objects.py", line 182, in get_properties
raise Exception("The CalDAV server you are using has "
Exception: The CalDAV server you are using has a problem with path handling.
我已经尝试尽可能多地使用 URL 来消除我这边可能出现的任何打字错误,但我仍然不能 100% 确定我做对了。
有人对我的案例中的最终异常消息有实际的解释吗?我可以在哪里继续寻找问题的解决方案?
我能够重现您的问题。解决方案是将 URL 中的日历名称从
更改为
pers%C3%B6nlich
到 pers%c3%b6nlich
注意 B
和 C
的大小写。
概览
我的目标是在 Raspberry Pi 上开发一个 Python 应用程序 运行,它通过网络读取 OwnCloud 日历条目。日历本身是 Owncloud 本地安装的一部分,它位于同一本地网络中的另一个 Raspberry Pi 上。进行请求时,访问是通过 HTTPS 完成的,无需主动 SSL 身份验证。
问题
我尝试使用 caldav Python 包。使用 PIP 和 Python v2.7 安装包后,我得到一个 Exception: The CalDAV server you are using has a problem with path handling.
这是我在 PYTHON IDLE v2.7 中输入的内容:
import caldav
cal_user='user'
cal_pass='pass'
cal_url='https://192.168.1.46/remote.php/caldav/calendars/user/pers%C3%B6nlich'
cal_client=caldav.DAVClient(cal_url, username='user', password='pass', ssl_verify_cert=False)
cal_principal=cal_client.principal()
这是控制台上打印的内容:
Warning (from warnings module):
File "C:\PROGS\Python27\lib\site-packages\requests\packages\urllib3\connectionpool.py", line 789
InsecureRequestWarning)
InsecureRequestWarning: Unverified HTTPS request is being made. Adding certificate verification is strongly advised. See: https://urllib3.readthedocs.org/en/latest/security.html
Warning (from warnings module):
File "C:\PROGS\Python27\lib\site-packages\requests\packages\urllib3\connectionpool.py", line 789
InsecureRequestWarning)
InsecureRequestWarning: Unverified HTTPS request is being made. Adding certificate verification is strongly advised. See: https://urllib3.readthedocs.org/en/latest/security.html
Traceback (most recent call last):
File "<pyshell#9>", line 1, in <module>
cal_principal=cal_client.principal()
File "C:\PROGS\Python27\lib\site-packages\caldav\davclient.py", line 113, in principal
return Principal(self)
File "C:\PROGS\Python27\lib\site-packages\caldav\objects.py", line 307, in __init__
cup = self.get_properties([dav.CurrentUserPrincipal()])
File "C:\PROGS\Python27\lib\site-packages\caldav\objects.py", line 182, in get_properties
raise Exception("The CalDAV server you are using has "
Exception: The CalDAV server you are using has a problem with path handling.
我已经尝试尽可能多地使用 URL 来消除我这边可能出现的任何打字错误,但我仍然不能 100% 确定我做对了。
有人对我的案例中的最终异常消息有实际的解释吗?我可以在哪里继续寻找问题的解决方案?
我能够重现您的问题。解决方案是将 URL 中的日历名称从
更改为pers%C3%B6nlich
到 pers%c3%b6nlich
注意 B
和 C
的大小写。