Unverified Commit e757d521 authored by Philip Meier's avatar Philip Meier Committed by GitHub
Browse files

add error message if Google Drive quota is exceeded (#2321)


Co-authored-by: default avatarFrancisco Massa <fvsmassa@gmail.com>
parent 5247f7b6
......@@ -118,6 +118,10 @@ def list_files(root, suffix, prefix=False):
return files
def _quota_exceeded(response: "requests.models.Response") -> bool:
return "Google Drive - Quota exceeded" in response.text
def download_file_from_google_drive(file_id, root, filename=None, md5=None):
"""Download a Google Drive file from and place it in root.
......@@ -150,6 +154,14 @@ def download_file_from_google_drive(file_id, root, filename=None, md5=None):
params = {'id': file_id, 'confirm': token}
response = session.get(url, params=params, stream=True)
if _quota_exceeded(response):
msg = (
f"The daily quota of the file {filename} is exceeded and it "
f"can't be downloaded. This is a limitation of Google Drive "
f"and can only be overcome by trying again later."
)
raise RuntimeError(msg)
_save_response_content(response, fpath)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment