如何使用easywebdav通过python连接到owncloud? [英] How can I connect to owncloud with python using easywebdav?
问题描述
我正在尝试使用 python 连接到 owncloud
实例.我发现 easywebdav
应该可以通过 webdav 轻松连接,但是在尝试连接时我收到404 Not Found"
I'm trying to connect to a owncloud
instance with python.
I've found easywebdav
that should make it easy to connect via webdav, but when trying to connect I'm getting "404 Not Found"
import easywebdav
webdav = easywebdav.connect('test.org/owncloud/remote.php/webdav/', username='user', password='pass', protocol='https', port=443, verify_ssl=False)
print webdav.ls(".")
我希望在我自己的云实例上找到一个文件列表,但我得到了
I would expect a list of files found on my owncloud instance, but I'm getting
python ./test.py
Traceback (most recent call last):
File "./test.py", line 8, in <module>
print webdav.ls(".")
File "/usr/lib/python2.7/site-packages/easywebdav-1.0.7-py2.7.egg/easywebdav/client.py", line 131, in ls
response = self._send('PROPFIND', remote_path, (207, 301), headers=headers)
File "/usr/lib/python2.7/site-packages/easywebdav-1.0.7-py2.7.egg/easywebdav/client.py", line 81, in _send
raise OperationFailed(method, path, expected_code, response.status_code)
easywebdav.client.OperationFailed: Failed to list directory ".".
Operation : PROPFIND .
Expected code : 207 UNKNOWN, 301 Moved Permanently
Actual code : 404 Not Found
我觉得奇怪的是,如果我连接到一个无效的路径,
What I find weird, is that if I connect to a invalid path, with
webdav = easywebdav.connect('test.org/owncloud-not-existent/', ......)
我明白了
Traceback (most recent call last):
File "./test.py", line 8, in <module>
print webdav.ls(".")
File "/usr/lib/python2.7/site-packages/easywebdav-1.0.7-py2.7.egg/easywebdav/client.py", line 131, in ls
response = self._send('PROPFIND', remote_path, (207, 301), headers=headers)
File "/usr/lib/python2.7/site-packages/easywebdav-1.0.7-py2.7.egg/easywebdav/client.py", line 81, in _send
raise OperationFailed(method, path, expected_code, response.status_code)
easywebdav.client.OperationFailed: Failed to list directory ".".
Operation : PROPFIND .
Expected code : 207 UNKNOWN, 301 Moved Permanently
Actual code : 405 Method Not Allowed
推荐答案
我用个人的 WebDav 服务器进行了测试,发现了类似的问题,虽然我认为我的 easywebdav 版本不同,但我使用的是 v1.0.7 和参数verify_ssl
是不允许的,所以我用http"做了测试.
I've tested with a personal WebDav server and I found a similar issue, although I think that my easywebdav version is different, I use v1.0.7 and the parameter verify_ssl
is not allowed, so I did the test with "http".
无论如何,我必须重现您的问题,修复它更改连接 url 并仅使用主机,将路径放在 ls()
命令中:
Anyway, I got to reproduce your issue, to fix it change the connection url and use only the host, putting the path in the ls()
command :
import easywebdav
webdav = easywebdav.connect('test.org', username='user', password='pass', protocol='https', port=443, verify_ssl=False)
print webdav.ls("/owncloud/remote.php/webdav")
这篇关于如何使用easywebdav通过python连接到owncloud?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!