From 6734460d42d553551b2986c159859255e243509c Mon Sep 17 00:00:00 2001 From: 2Shirt <2xShirt@gmail.com> Date: Sun, 14 Apr 2019 17:01:53 -0700 Subject: [PATCH] Added option to skip pause in abort() * Also use exit_script(1) --- .bin/Scripts/build-ufd | 12 ++++++------ .bin/Scripts/functions/common.py | 9 +++++---- 2 files changed, 11 insertions(+), 10 deletions(-) diff --git a/.bin/Scripts/build-ufd b/.bin/Scripts/build-ufd index 610a1e66..5542a0ac 100755 --- a/.bin/Scripts/build-ufd +++ b/.bin/Scripts/build-ufd @@ -66,10 +66,10 @@ if __name__ == '__main__': except FileNotFoundError: print_error('ERROR: UFD device not found: {}'.format( args['--ufd-device'])) - abort() + abort(False) if not is_valid_path(ufd_dev, 'UFD'): print_error('ERROR: Invalid UFD device: {}'.format(ufd_dev)) - abort() + abort(False) ## Sources for label, data in UFD_SOURCES.items(): s_path = args[data['Arg']] @@ -78,10 +78,10 @@ if __name__ == '__main__': s_path_obj = find_path(s_path) except FileNotFoundError: print_error('ERROR: {} not found: {}'.format(label, s_path)) - abort() + abort(False) if not is_valid_path(s_path_obj, data['Type']): print_error('ERROR: Invalid {} source: {}'.format(label, s_path)) - abort() + abort(False) sources[label] = s_path_obj # Show selections @@ -125,7 +125,7 @@ if __name__ == '__main__': print_warning('Formatting using legacy MBR') print_standard(' ') if not ask('Is the above information correct?'): - abort() + abort(False) ## Safety check if not args['--update']: print_standard(' ') @@ -136,7 +136,7 @@ if __name__ == '__main__': 'This is irreversible and will lead to {RED}DATA LOSS.{CLEAR}'.format( **COLORS)) if not ask('Asking again to confirm, is this correct?'): - abort() + abort(False) print_standard(' ') print_success("It's go-time!") diff --git a/.bin/Scripts/functions/common.py b/.bin/Scripts/functions/common.py index b6008d27..fe75f1ef 100644 --- a/.bin/Scripts/functions/common.py +++ b/.bin/Scripts/functions/common.py @@ -90,12 +90,13 @@ class SecureBootUnknownError(Exception): # General functions -def abort(): +def abort(show_prompt=True): """Abort script.""" print_warning('Aborted.') - sleep(1) - pause(prompt='Press Enter to exit... ') - exit_script() + if show_prompt: + sleep(timeout) + pause(prompt='Press Enter to exit... ') + exit_script(1) def ask(prompt='Kotaero!'):