Catch KeyboardInterupt in download_file
When interupting a download with something like control c the program will quit but won't clean it self up and will leave an invalid file. There is a handler for Exception, but this wont catch interupts. If you try to rerun the program it won't try to redownload it the next time.
This commit is contained in:
4
emsdk
4
emsdk
@@ -487,6 +487,10 @@ def download_file(url, dstpath, download_even_if_exists=False, filename_prefix =
|
|||||||
print("Error downloading URL '" + url + "': " + str(e))
|
print("Error downloading URL '" + url + "': " + str(e))
|
||||||
rmfile(file_name)
|
rmfile(file_name)
|
||||||
return None
|
return None
|
||||||
|
except KeyboardInterrupt as e:
|
||||||
|
print("Received Interrupt, exiting")
|
||||||
|
rmfile(file_name)
|
||||||
|
exit(0)
|
||||||
return file_name
|
return file_name
|
||||||
|
|
||||||
def download_text_file(url, dstpath, download_even_if_exists=False, filename_prefix=''):
|
def download_text_file(url, dstpath, download_even_if_exists=False, filename_prefix=''):
|
||||||
|
|||||||
Reference in New Issue
Block a user