From 1e21b1bd59dfa37ab6af182352d9fe1b23d0d383 Mon Sep 17 00:00:00 2001 From: 2Shirt <2xShirt@gmail.com> Date: Tue, 19 Mar 2019 20:24:42 -0600 Subject: [PATCH] Match formatting when enabling Windows Updates --- .bin/Scripts/functions/windows_updates.py | 21 ++++++++++++++------- .bin/Scripts/system_checklist.py | 3 ++- 2 files changed, 16 insertions(+), 8 deletions(-) diff --git a/.bin/Scripts/functions/windows_updates.py b/.bin/Scripts/functions/windows_updates.py index 36a390ad..3618fbb2 100644 --- a/.bin/Scripts/functions/windows_updates.py +++ b/.bin/Scripts/functions/windows_updates.py @@ -71,7 +71,7 @@ def enable_service(service_name, start_type='auto'): run_program(['sc', 'config', service_name, 'start=', start_type]) -def enable_windows_updates(): +def enable_windows_updates(silent=False): """Enable windows updates""" indent=2 width=52 @@ -81,17 +81,24 @@ def enable_windows_updates(): start_type = 'auto' if service == 'wuauserv': start_type = 'demand' - result = try_and_print( - 'Enabling service {}...'.format(service), - indent=indent, width=width, - function=enable_service, service_name=service, start_type=start_type) - if not result['CS']: + if silent: + try: + enable_service(service, start_type=start_type) + except Exception: + # Try again + enable_service(service, start_type=start_type) + else: result = try_and_print( 'Enabling service {}...'.format(service), indent=indent, width=width, function=enable_service, service_name=service, start_type=start_type) if not result['CS']: - raise GenericError('Service {} could not be enabled.'.format(service)) + result = try_and_print( + 'Enabling service {}...'.format(service), + indent=indent, width=width, + function=enable_service, service_name=service, start_type=start_type) + if not result['CS']: + raise GenericError('Service {} could not be enabled.'.format(service)) def get_service_status(service_name): diff --git a/.bin/Scripts/system_checklist.py b/.bin/Scripts/system_checklist.py index 3bd3772d..1088cf5d 100644 --- a/.bin/Scripts/system_checklist.py +++ b/.bin/Scripts/system_checklist.py @@ -57,7 +57,8 @@ if __name__ == '__main__': function=enable_system_restore, cs='Done') try_and_print(message='Create System Restore point...', function=create_system_restore_point, cs='Done') - enable_windows_updates() + try_and_print(message='Enabling Windows Updates...', + function=enable_windows_updates, cs='Done', silent=True) try_and_print(message='Updating Clock...', function=update_clock, cs='Done')