Leave SW Diags window open in D7_MODE on error(s)

This commit is contained in:
2Shirt 2018-08-19 12:26:58 -07:00
parent 4e022ed843
commit 39f947bdd1
Signed by: 2Shirt
GPG key ID: 152FAC923B0E132C

View file

@ -16,6 +16,17 @@ os.system('title {}: System Diagnostics Tool'.format(KIT_NAME_FULL))
global_vars['LogFile'] = r'{LogDir}\System Diagnostics.log'.format( global_vars['LogFile'] = r'{LogDir}\System Diagnostics.log'.format(
**global_vars) **global_vars)
D7_MODE = 'd7mode' in sys.argv D7_MODE = 'd7mode' in sys.argv
ERRORS = 0
def check_result(result, other_results):
"""Check result for warnings and errors."""
if not result['CS']:
for warning in other_results.get('Warning', {}).keys():
if warning in str(result['Error']):
# Ignore warnings and repair statements
return
# Error is not a warning
ERRORS += 1
if __name__ == '__main__': if __name__ == '__main__':
try: try:
@ -58,14 +69,17 @@ if __name__ == '__main__':
# OS Health Checks # OS Health Checks
print_info('OS Health Checks') print_info('OS Health Checks')
try_and_print( result = try_and_print(
message='CHKDSK ({SYSTEMDRIVE})...'.format(**global_vars['Env']), message='CHKDSK ({SYSTEMDRIVE})...'.format(**global_vars['Env']),
function=run_chkdsk, other_results=other_results) function=run_chkdsk, other_results=other_results)
try_and_print(message='SFC scan...', check_result(result, other_results)
result = try_and_print(message='SFC scan...',
function=run_sfc_scan, other_results=other_results) function=run_sfc_scan, other_results=other_results)
check_result(result, other_results)
if D7_MODE: if D7_MODE:
try_and_print(message='DISM RestoreHealth...', result = try_and_print(message='DISM RestoreHealth...',
function=run_dism, other_results=other_results, repair=True) function=run_dism, other_results=other_results, repair=True)
check_result(result, other_results)
else: else:
try_and_print(message='DISM CheckHealth...', try_and_print(message='DISM CheckHealth...',
function=run_dism, other_results=other_results, repair=False) function=run_dism, other_results=other_results, repair=False)
@ -127,7 +141,7 @@ if __name__ == '__main__':
print_error(' Unknown error.') print_error(' Unknown error.')
# Done # Done
if not D7_MODE: if not D7_MODE or ERRORS > 0:
print_standard('\nDone.') print_standard('\nDone.')
pause('Press Enter to exit...') pause('Press Enter to exit...')
exit_script() exit_script()