This commit is contained in:
Glenn Jocher 2019-08-04 17:50:20 +02:00
parent f0762134ce
commit 4db005cd9b
1 changed files with 22 additions and 18 deletions

View File

@ -2,18 +2,19 @@
# pip install --upgrade google-cloud-storage # pip install --upgrade google-cloud-storage
import os import os
import time
# from google.cloud import storage # from google.cloud import storage
def gdrive_download(files=(('1HaXkef9z6y5l4vUnCYgdmEAj61c6bfWO', 'coco.zip'))): def gdrive_download(id='1HaXkef9z6y5l4vUnCYgdmEAj61c6bfWO', name='coco.zip'):
# https://gist.github.com/tanaikech/f0f2d122e05bf5f971611258c22c110f # https://gist.github.com/tanaikech/f0f2d122e05bf5f971611258c22c110f
# Downloads a file from Google Drive, accepting presented query # Downloads a file from Google Drive, accepting presented query
# from utils.google_utils import *; gdrive_download() # from utils.google_utils import *; gdrive_download()
t = time.time()
for (id, name) in files: print('Downloading https://drive.google.com/uc?export=download&id=%s as %s... ' % (id, name))
print('Downloading ''https://drive.google.com/uc?export=download&id=%s'' as ''%s''...' % (id, name))
if os.path.exists(name): # remove existing if os.path.exists(name): # remove existing
os.remove(name) os.remove(name)
@ -31,8 +32,11 @@ def gdrive_download(files=(('1HaXkef9z6y5l4vUnCYgdmEAj61c6bfWO', 'coco.zip'))):
# Unzip if archive # Unzip if archive
if name.endswith('.zip'): if name.endswith('.zip'):
print('Unzipping %s... ' % name, end='')
os.system('unzip -q %s' % name) os.system('unzip -q %s' % name)
print('Done (%.1fs)' % (time.time()-t))
def upload_blob(bucket_name, source_file_name, destination_blob_name): def upload_blob(bucket_name, source_file_name, destination_blob_name):
# Uploads a file to a bucket # Uploads a file to a bucket