Objects365 Update

This commit is contained in:
Glenn Jocher committed 2021-05-04 02:25:14 +02:00
1 parent b292837e36
commit 5189b3addb
3 files changed
+46 -48

No files matched your search

+6 -3
View File
@@ -193,7 +193,7 @@ def check_dataset(dict):
raise Exception('Dataset not found.')
def download(url, dir='.', unzip=True, curl=False, threads=1):
def download(url, dir='.', unzip=True, delete=True, curl=False, threads=1):
# Multi-threaded file download and unzip function
def download_one(url, dir):
# Download 1 file
@@ -207,9 +207,12 @@ def download(url, dir='.', unzip=True, curl=False, threads=1):
if unzip and f.suffix in ('.zip', '.gz'):
print(f'Unzipping {f}...')
if f.suffix == '.zip':
os.system(f'unzip -qo {f} -d {dir} && rm {f}') # unzip -quiet -overwrite
s = f'unzip -qo {f} -d {dir} && rm {f}' # unzip -quiet -overwrite
elif f.suffix == '.gz':
os.system(f'tar xfz {f} --directory {f.parent} && rm {f}') # unzip
s = f'tar xfz {f} --directory {f.parent}' # unzip
if delete: # delete zip file after unzip
s += f' && rm {f}'
os.system(s)
dir = Path(dir)
dir.mkdir(parents=True, exist_ok=True) # make directory