Replace os.system('unzip file.zip') -> ZipFile.extractall() (#4919)
* Replace `os.system('unzip file.zip')` -> `ZipFile.extractall()`
* Cleanup
This commit is contained in:
1 parent
1492632796
commit
a64a4c839f
3 files changed
+16
-12
No files matched your search
+3
-2
@@ -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
|
||||
|
||||
Reference in new issue
Block a user