Match formatting when enabling Windows Updates
This commit is contained in:
parent
3f96a31e1e
commit
1e21b1bd59
2 changed files with 16 additions and 8 deletions
|
|
@ -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):
|
||||
|
|
|
|||
|
|
@ -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')
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue