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

gdown.download should raise an exception if access is denied #276

Open
nutjob4life opened this issue Jul 27, 2023 · 1 comment
Open

gdown.download should raise an exception if access is denied #276

nutjob4life opened this issue Jul 27, 2023 · 1 comment
Labels
bug for issue

Comments

@nutjob4life
Copy link

Provide environment information

  • Python 3.11.4
  • gdown 4.7.1

What OS are you using?

macOS 13.4

Describe the Bug

In some deeply embedded code, an autonomous system calls

fd, fn = tempfile.mkstemp('.xlsx')
os.close(fd)
gdown.download(id=file_identifier, output=fn, quiet=True, use_cookies=False, format='xlsx')

and an unexpected error occurs later in the system when the supposedly downloaded file is read:

sheet = pandas.read_excel(fn)

with the error:

ValueError: Excel file format cannot be determined, you must specify an engine manually

The problem being that the file fn is actually empty. The real error is:

Cannot retrieve the public link of the file. You may need to change the permission to 'Anyone with the link', or have had many accesses. 

We expected gdown.download to raise an exception on error.

Expected Behavior

An exception to be raised on exceptional conditions.

Alternatively, the docstring should indicate how the return value is used to indicate exceptional conditions.

To Reproduce

  1. Create a file in GDrive and ensure it's not public
  2. gdown.download that file
  3. See if an exception is raised

The workaround is to do what gdown.cli does: check the return value and if it's None, manually raise an exception.

Otherwise, thanks so much for gdown! It's really quite superb otherwise 😇

@nutjob4life nutjob4life added the bug for issue label Jul 27, 2023
nutjob4life added a commit to EDRN/P5 that referenced this issue Aug 2, 2023
- Add root objects to CDE Explorer's page context so we can have them pre-sorted alphabetically
- `gdown.download` doesn't raise an exception on error but returns None as the written filename, so test for this condition and raise our own exception (wkentaro/gdown#276)
- Make `update_nodes` "public" since we expect to call this from outside the class context
- When installing the CDE explorer, put it on the EDRN CDE page, not the LabCAS page. Also make it stand out. Also, initially populate it. Also, call it the "EDRN Data Model", not the "LabCAS CDEs"
- Make required CDEs stand out with color and icon
- Move the "Update from Google Drive" button appear next to the "View Update Log" button
- Hide the "Attributes" heading entirely if there are no attributes
@m-pektas
Copy link

I don't understand, there is no new release but I got this error today. I fixed it downgrading the version to 4.6.0.

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

No branches or pull requests

2 participants