cthoyt / zenodo-client

A tool for automated uploading and version management of scientific data to Zenodo
MIT License
25 stars 5 forks source link

Failed to download a file from a closed deposition #11

Closed longavailable closed 1 year ago

longavailable commented 1 year ago

scritps

from zenodo_client import Zenodo
zenodo = Zenodo(sandbox=True)
recordid = '1165283'                         # It is from a closed deposition
new_record = zenodo.download_latest(recordid, 'config.ini')

returns

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/local/python/3.10.4/lib/python3.10/site-packages/zenodo_client/api.py", line 291, in download_latest
    return self.download(latest_record_id, name=name, force=force, parts=parts)
  File "/usr/local/python/3.10.4/lib/python3.10/site-packages/zenodo_client/api.py", line 279, in download
    return pystow.ensure(*parts, name=name, url=url, force=force)
  File "/usr/local/python/3.10.4/lib/python3.10/site-packages/pystow/api.py", line 205, in ensure
    return _module.ensure(
  File "/usr/local/python/3.10.4/lib/python3.10/site-packages/pystow/impl.py", line 177, in ensure
    utils.download(
  File "/usr/local/python/3.10.4/lib/python3.10/site-packages/pystow/utils.py", line 317, in download
    urlretrieve(url, path, **kwargs)  # noqa:S310
  File "/usr/local/python/3.10.4/lib/python3.10/urllib/request.py", line 241, in urlretrieve
    with contextlib.closing(urlopen(url, data)) as fp:
  File "/usr/local/python/3.10.4/lib/python3.10/urllib/request.py", line 216, in urlopen
    return opener.open(url, data, timeout)
  File "/usr/local/python/3.10.4/lib/python3.10/urllib/request.py", line 525, in open
    response = meth(req, response)
  File "/usr/local/python/3.10.4/lib/python3.10/urllib/request.py", line 634, in http_response
    response = self.parent.error(
  File "/usr/local/python/3.10.4/lib/python3.10/urllib/request.py", line 563, in error
    return self._call_chain(*args)
  File "/usr/local/python/3.10.4/lib/python3.10/urllib/request.py", line 496, in _call_chain
    result = func(*args)
  File "/usr/local/python/3.10.4/lib/python3.10/urllib/request.py", line 643, in http_error_default
    raise HTTPError(req.full_url, code, msg, hdrs, fp)
urllib.error.HTTPError: HTTP Error 404: NOT FOUND

What I guess

It works fine for a open deposition. Well, not for a closed one. So, I guess, the authorization was not set correctly in pystow.

cthoyt commented 1 year ago

Hi @longavailable, maybe I'm misunderstanding - are you saying that Zenodo has the possibility to have records that require authorization? I've never come across something like this before

longavailable commented 1 year ago

Hi @cthoyt

Yes. As it is, , four types of access are supported. They are open, embargoed, restricted and closed. It also can be found in the Access and Reuse | General Policies.

For a new update/deposit, the access type should be chosed in the [license] part.

The latter three types may require authorization.

cthoyt commented 1 year ago

Thanks for the information. I’m not so interested to spend my free time supporting non-open science, so if this is a feature you absolutely need then I would be open to discussing a consulting agreement.