updates
This commit is contained in:
parent
7e92f70e05
commit
f3d3295f90
|
@ -15,25 +15,23 @@ def gdrive_download(id='1HaXkef9z6y5l4vUnCYgdmEAj61c6bfWO', name='coco.zip'):
|
||||||
t = time.time()
|
t = time.time()
|
||||||
|
|
||||||
print('Downloading https://drive.google.com/uc?export=download&id=%s as %s... ' % (id, name), end='')
|
print('Downloading https://drive.google.com/uc?export=download&id=%s as %s... ' % (id, name), end='')
|
||||||
if os.path.exists(name): # remove existing
|
os.remove(name) if os.path.exists(name) else None # remove existing
|
||||||
os.remove(name)
|
os.remove('cookie') if os.path.exists('cookie') else None
|
||||||
|
|
||||||
# Attempt large file download
|
# Attempt file download
|
||||||
s = ["curl -c ./cookie -s -L \"https://drive.google.com/uc?export=download&id=%s\" > /dev/null" % id,
|
os.system("curl -c ./cookie -s -L \"https://drive.google.com/uc?export=download&id=%s\" > /dev/null" % id)
|
||||||
"curl -Lb ./cookie -s \"https://drive.google.com/uc?export=download&confirm=`awk '/download/ {print $NF}' ./cookie`&id=%s\" -o %s" % (
|
if os.path.exists('cookie'): # large file
|
||||||
id, name),
|
s = "curl -Lb ./cookie -s \"https://drive.google.com/uc?export=download&confirm=`awk '/download/ {print $NF}' ./cookie`&id=%s\" -o %s" % (
|
||||||
'rm ./cookie']
|
id, name)
|
||||||
r = sum([os.system(x) for x in s][:2]) # run commands, get return zeros
|
else: # small file
|
||||||
|
|
||||||
# Attempt small file download
|
|
||||||
if not os.path.exists(name): # file size < 40MB
|
|
||||||
s = 'curl -f -L -o %s https://drive.google.com/uc?export=download&id=%s' % (name, id)
|
s = 'curl -f -L -o %s https://drive.google.com/uc?export=download&id=%s' % (name, id)
|
||||||
r = os.system(s)
|
r = os.system(s) # execute, capture return values
|
||||||
|
os.remove('cookie') if os.path.exists('cookie') else None
|
||||||
|
|
||||||
# Error check
|
# Error check
|
||||||
if r != 0:
|
if r != 0:
|
||||||
os.system('rm ' + name) # remove partial downloads
|
os.remove(name) if os.path.exists(name) else None # remove partial
|
||||||
print('ERROR: Download failure ')
|
print('Download error ') # raise Exception('Download error')
|
||||||
return r
|
return r
|
||||||
|
|
||||||
# Unzip if archive
|
# Unzip if archive
|
||||||
|
|
Loading…
Reference in New Issue