Replace os.system('unzip file.zip') -> ZipFile.extractall() (#4919)

* Replace `os.system('unzip file.zip')` -> `ZipFile.extractall()`

* Cleanup
This commit is contained in:
Glenn Jocher authored and GitHub committed 2021-09-25 08:52:36 -07:00
1 parent 1492632796
commit a64a4c839f
3 files changed
+16 -12

No files matched your search

+3 -2
View File
@@ -9,6 +9,7 @@ import subprocess
import time
import urllib
from pathlib import Path
from zipfile import ZipFile
import requests
import torch
@@ -104,8 +105,8 @@ def gdrive_download(id='16TiPfZj7htmTyhntwcZyEEAejOUxuT6m', file='tmp.zip'):
# Unzip if archive
if file.suffix == '.zip':
print('unzipping... ', end='')
os.system(f'unzip -q {file}') # unzip
file.unlink() # remove zip to free space
ZipFile(file).extractall(path=file.parent) # unzip
file.unlink() # remove zip
print(f'Done ({time.time() - t:.1f}s)')
return r