Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

webdav3.exceptions.MethodNotSupported #126

Open
Tim-IA opened this issue Aug 30, 2022 · 1 comment
Open

webdav3.exceptions.MethodNotSupported #126

Tim-IA opened this issue Aug 30, 2022 · 1 comment

Comments

@Tim-IA
Copy link

Tim-IA commented Aug 30, 2022

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
Copy link

Ed1ks commented Dec 5, 2023

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:

  1. download_sync()
  2. download()
  3. download_file()

This is broken and needs to be fixed!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants