From c1a7d52fdc0fc8537fe2a40803fe374eaa7fe333 Mon Sep 17 00:00:00 2001 From: matthew Date: Sun, 12 Nov 2017 21:43:26 -0800 Subject: [PATCH 1/2] 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. --- emsdk | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/emsdk b/emsdk index 6eda2ee..3441cb1 100755 --- a/emsdk +++ b/emsdk @@ -487,6 +487,10 @@ def download_file(url, dstpath, download_even_if_exists=False, filename_prefix = print("Error downloading URL '" + url + "': " + str(e)) rmfile(file_name) return None + except KeyboardInterrupt as e: + print("Received Interrupt, exiting") + rmfile(file_name) + exit(0) return file_name def download_text_file(url, dstpath, download_even_if_exists=False, filename_prefix=''): From 86c79dec0a8fe4aaf562bcc36b7964d6d9a42c7e Mon Sep 17 00:00:00 2001 From: matthew Date: Mon, 13 Nov 2017 20:39:44 -0800 Subject: [PATCH 2/2] Change exit code and error message --- emsdk | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/emsdk b/emsdk index 3441cb1..44da683 100755 --- a/emsdk +++ b/emsdk @@ -488,9 +488,9 @@ def download_file(url, dstpath, download_even_if_exists=False, filename_prefix = rmfile(file_name) return None except KeyboardInterrupt as e: - print("Received Interrupt, exiting") + print("Aborted by User, exiting") rmfile(file_name) - exit(0) + exit(1) return file_name def download_text_file(url, dstpath, download_even_if_exists=False, filename_prefix=''):