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:
matthew
2017-11-12 21:43:26 -08:00
parent 00e8d9df95
commit c1a7d52fdc

4
emsdk
View File

@@ -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=''):