webdav3.exceptions.MethodNotSupported
Tim-IA opened this issue · 1 comments
Tim-IA commented
from webdav3.client import Client
import requests, yaml, logging, os
PATH="/share/document/"
NAS="NAS/"
NAS_file="NAS.pdf"
remote=PATH+NAS
remote_path=PATH+NAS+NAS_file
local_path="./Docs/"
logging.captureWarnings(True)
doc="http://.com"
with open('config.yaml') as f:
config = yaml.load(f, Loader=yaml.loader.SafeLoader)
options = {
'webdav_hostname': doc,
'webdav_login': config['login'],
'webdav_password': config["password"],
'webdav_override_methods': {
'check': 'GET'
}
}
client = Client(options)
print(client.webdav.is_valid())
# client.verify = False
client.default_options['SSL_VERIFYPEER'] = False
client.default_options['SSL_VERIFYHOST'] = False
client.download_sync(remote_path=remote_path, local_path=local_path)
Python output:
webdav3.exceptions.MethodNotSupported: Method 'is_dir' not supported for http://.com
Ed1ks commented
The reason for this error is:
def parse_is_dir_response(content, path, hostname):
"""Parses of response content XML from WebDAV server and extract an information about resource.
:param content: the XML content of HTTP response from WebDAV server.
:param path: the path to resource.
:param hostname: the server hostname.
:return: True in case the remote resource is directory and False otherwise.
"""
response = WebDavXmlUtils.extract_response_for_path(content=content, path=path, hostname=hostname)
resource_type = response.find(".//{DAV:}resourcetype")
if resource_type is None:
raise MethodNotSupported(name="is_dir", server=hostname)
dir_type = resource_type.find("{DAV:}collection")
return True if dir_type is not None else False
it requires 'resourcetype' and 'collection' in xml, which dont exists.
If you download something with download_sync() it makes 3 times is_dir checks with requests:
- download_sync()
- download()
- download_file()
This is broken and needs to be fixed!