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

Can list() files, but cannot download. "Remote resource not found" #145

Open
sunithb opened this issue Apr 3, 2024 · 2 comments
Open

Can list() files, but cannot download. "Remote resource not found" #145

sunithb opened this issue Apr 3, 2024 · 2 comments

Comments

@sunithb
Copy link

sunithb commented Apr 3, 2024

python 3.11
webdav3 3.14.5

I can connect to the WebDAV server (NextCloud) and list the files as follows:

client.list("Transfer/openvino/carpet/") 

['carpet/', 'metadata.json', 'model.bin', 'model.onnx', 'model.xml', 'notebook1.py', 'openvino_inferencer.py', 'test.zip']

But when I try to download 'model.bin', I get the following error

client.download_file("Transfer/openvino/carpet/model.bin","~/model.bin") 

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/device1531/openvino_env/lib/python3.11/site-packages/webdav3/client.py", line 67, in _wrapper
    res = fn(self, *args, **kw)
          ^^^^^^^^^^^^^^^^^^^^^
  File "/home/device1531/openvino_env/lib/python3.11/site-packages/webdav3/client.py", line 447, in download_file
    if self.is_dir(urn.path()):
       ^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/device1531/openvino_env/lib/python3.11/site-packages/webdav3/client.py", line 67, in _wrapper
    res = fn(self, *args, **kw)
          ^^^^^^^^^^^^^^^^^^^^^
  File "/home/device1531/openvino_env/lib/python3.11/site-packages/webdav3/client.py", line 781, in is_dir
    return WebDavXmlUtils.parse_is_dir_response(content=response.content, path=path, hostname=self.webdav.hostname)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/device1531/openvino_env/lib/python3.11/site-packages/webdav3/client.py", line 1164, in parse_is_dir_response
    response = WebDavXmlUtils.extract_response_for_path(content=content, path=path, hostname=hostname)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/device1531/openvino_env/lib/python3.11/site-packages/webdav3/client.py", line 1251, in extract_response_for_path
    raise RemoteResourceNotFound(path)
webdav3.exceptions.RemoteResourceNotFound: Remote resource: /Transfer/openvino/carpet/model.bin not found
@FaKe2008
Copy link

I had the same problem. In my case, it was because I had already indicated part of the path in the webdav_host_address. With this information, the response of the WebDAV server could not be parsed correctly. Since I had no influence on the specification of the webdav_host_address, I helped myself by using prefix = urlparse(webdav_host_address).path (module urllib.parse), removing the prefix from the webdav_host_address and prefixing it again later to get and put calls.

@Marius089
Copy link

I have the same problem. Parsing the path did not help. Any other solutions??

from webdav3.client import Client

options = {
'webdav_hostname': "https://webdisk.ads.mwn.de/hcwebdav/Home",
'webdav_login': "xxx",
'webdav_password': "yyy",
'webdav_override_methods': {
'check': 'GET'},
'disable_check': True
}

client = Client(options)

check = client.check("Test_1/Textdok_1.txt")
print(check) Output: TRUE
client.download("Test_1/Textdok_1.txt", local_path= r'/content/TEST.txt')


RemoteResourceNotFound Traceback (most recent call last)

in <cell line: 3>()
1 files = client.check("/hcwebdav/Home/Test_1/Textdok_1.txt")
2 print(files)
----> 3 client.download("/hcwebdav/Home/Test_1/Textdok_1.txt", local_path= r'/content/TEST.txt')

3 frames

/usr/local/lib/python3.10/dist-packages/webdav3/client.py in download(self, remote_path, local_path, progress, progress_args)
391 """
392 urn = Urn(remote_path)
--> 393 if self.is_dir(urn.path()):
394 self.download_directory(local_path=local_path, remote_path=remote_path, progress=progress,
395 progress_args=progress_args)

/usr/local/lib/python3.10/dist-packages/webdav3/client.py in _wrapper(self, *args, **kw)
65 log.debug("Requesting %s(%s, %s)", fn, args, kw)
66 try:
---> 67 res = fn(self, *args, **kw)
68 except requests.ConnectionError:
69 raise NoConnection(self.webdav.hostname)

/usr/local/lib/python3.10/dist-packages/webdav3/client.py in is_dir(self, remote_path)
777 self._check_remote_resource(remote_path, urn)
778
--> 779 response = self.execute_request(action='info', path=urn.quote(), headers_ext=["Depth: 0"])
780 path = self.get_full_path(urn)
781 return WebDavXmlUtils.parse_is_dir_response(content=response.content, path=path, hostname=self.webdav.hostname)

/usr/local/lib/python3.10/dist-packages/webdav3/client.py in execute_request(self, action, path, data, headers_ext)
224 raise NotEnoughSpace()
225 if response.status_code == 404:
--> 226 raise RemoteResourceNotFound(path=path)
227 if response.status_code == 405:
228 raise MethodNotSupported(name=action, server=self.webdav.hostname)

RemoteResourceNotFound: Remote resource: /hcwebdav/Home/Test_1/Textdok_1.txt not found

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

3 participants