From 8ad9e834efc4d2eb59fcfe3fe2c193a074efb822 Mon Sep 17 00:00:00 2001 From: 2Shirt <2xShirt@gmail.com> Date: Sun, 12 May 2019 18:13:42 -0600 Subject: [PATCH] Moved check_os_and_abort logic to its own function --- .bin/Scripts/system_setup.py | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/.bin/Scripts/system_setup.py b/.bin/Scripts/system_setup.py index b3f8279a..c1d8321a 100644 --- a/.bin/Scripts/system_setup.py +++ b/.bin/Scripts/system_setup.py @@ -155,6 +155,19 @@ SETUP_QUESTIONS = { # Functions +def check_os_and_abort(): + """Check OS and prompt to abort if not supported.""" + result = try_and_print( + message='OS support status...', + function=check_os_support_status, + cs='GOOD', + ) + if not result['CS'] and 'Unsupported' in result['Error']: + print_warning('OS version not supported by this script') + if not ask('Continue anyway? (NOT RECOMMENDED)'): + abort() + + def get_actions(setup_mode, answers): """Get actions to perform based on setup_mode, returns OrderedDict.""" actions = OrderedDict({}) @@ -292,15 +305,7 @@ def main(): clear_screen() # Check installed OS - result = try_and_print( - message='OS support status...', - function=check_os_support_status, - cs='GOOD', - ) - if not result['CS'] and 'Unsupported' in result['Error']: - print_warning('OS version not supported by this script') - if not ask('Continue anyway? (NOT RECOMMENDED)'): - abort() + check_os_and_abort() # Get setup mode setup_mode = get_mode()