|
|
@ -15,6 +15,9 @@ class BasicDownloader():
|
|
|
|
|
|
|
|
|
|
|
|
max_tries = 5
|
|
|
|
max_tries = 5
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def __init__(self):
|
|
|
|
|
|
|
|
self.downloading = False
|
|
|
|
|
|
|
|
|
|
|
|
def download(self, url, pathfmt):
|
|
|
|
def download(self, url, pathfmt):
|
|
|
|
"""Download the resource at 'url' and write it to a file-like object"""
|
|
|
|
"""Download the resource at 'url' and write it to a file-like object"""
|
|
|
|
try:
|
|
|
|
try:
|
|
|
@ -22,6 +25,7 @@ class BasicDownloader():
|
|
|
|
except:
|
|
|
|
except:
|
|
|
|
# remove file if download failed
|
|
|
|
# remove file if download failed
|
|
|
|
try:
|
|
|
|
try:
|
|
|
|
|
|
|
|
if self.downloading:
|
|
|
|
os.unlink(pathfmt.realpath)
|
|
|
|
os.unlink(pathfmt.realpath)
|
|
|
|
except (AttributeError, FileNotFoundError):
|
|
|
|
except (AttributeError, FileNotFoundError):
|
|
|
|
pass
|
|
|
|
pass
|
|
|
|