我正在尝试owncloud
使用 python 连接到一个实例。我发现easywebdav
应该可以很容易地通过 webdav 进行连接,但是在尝试连接时我得到“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(".")
我希望在我自己的云实例上找到一个文件列表,但我得到了
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
我觉得奇怪的是,如果我连接到无效路径,使用
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