From 0a4f87b0ce271d2d5e69b9c45ed0e1c9a26ed20a Mon Sep 17 00:00:00 2001 From: 2Shirt <2xShirt@gmail.com> Date: Mon, 18 Nov 2019 19:38:56 -0700 Subject: [PATCH] More checkbox updates --- .bin/Scripts/functions/hw_diags.py | 55 +++++++++++++++--------------- 1 file changed, 28 insertions(+), 27 deletions(-) diff --git a/.bin/Scripts/functions/hw_diags.py b/.bin/Scripts/functions/hw_diags.py index f8fe1d73..8f49df42 100644 --- a/.bin/Scripts/functions/hw_diags.py +++ b/.bin/Scripts/functions/hw_diags.py @@ -41,11 +41,11 @@ class CpuObj(): def all_tests_passed(self): """Check if all tests passed, returns bool.""" - return all([results.passed for results in self.tests.values()]) + return self.tests and all([results.passed for results in self.tests.values()]) def any_test_failed(self): """Check if any test failed, returns bool.""" - return any([results.failed for results in self.tests.values()]) + return self.tests and any([results.failed for results in self.tests.values()]) def get_details(self): """Get CPU details from lscpu.""" @@ -127,11 +127,11 @@ class DiskObj(): def all_tests_passed(self): """Check if all tests passed, returns bool.""" - return all([results.passed for results in self.tests.values()]) + return self.tests and all([results.passed for results in self.tests.values()]) def any_test_failed(self): """Check if any test failed, returns bool.""" - return any([results.failed for results in self.tests.values()]) + return self.tests and any([results.failed for results in self.tests.values()]) def calc_io_dd_values(self): """Calcualte I/O benchmark dd values. @@ -1297,28 +1297,12 @@ def run_hw_tests(state): print_warning('Errors encountered posting results to osTicket.') print_standard(' ') - # Upload for review - if (ENABLED_UPLOAD_DATA - and DEBUG_MODE - and ask('Upload results for review?')): - try_and_print( - message='Saving debug reports...', - function=save_debug_reports, - state=state, global_vars=global_vars) - try_and_print( - message='Uploading Data...', - function=upload_logdir, - global_vars=global_vars, - reason='Review') - # Do we need to update checkboxes? - all_disks_passed = all([disk.all_tests_passed() for disk in state.disks]) + all_disks_passed = state.disks and all([disk.all_tests_passed() for disk in state.disks]) all_disk_tests_enabled = all( [state.tests[name]['Enabled'] for name in TESTS_DISK]) - any_disk_failures = any([disk.any_test_failed() for disk in state.disks]) + any_disk_failures = state.disks and any([disk.any_test_failed() for disk in state.disks]) cpu_failed = state.cpu.any_test_failed() - cpu_max_temp = get_cpu_max_temp(state.cpu.sensor_data) - cpu_max_temp = f'{cpu_max_temp:2.0f}' cpu_passed = state.cpu.all_tests_passed() update_checkboxes = False if state.ticket_id: @@ -1333,11 +1317,14 @@ def run_hw_tests(state): # Ask to update checkboxes if update_checkboxes and ask('Update checkboxes using above results?'): # CPU checkboxes - if cpu_failed: - state.ost.set_cpu_failed(state.ticket_id) - elif cpu_passed: - state.ost.set_cpu_passed(state.ticket_id) - state.ost.set_cpu_temp(state.ticket_id, temp=cpu_max_temp) + if state.tests['Prime95']['Enabled']: + cpu_max_temp = get_cpu_max_temp(state.cpu.tests['Prime95'].sensor_data) + cpu_max_temp = f'{cpu_max_temp:2.0f}' + if cpu_failed: + state.ost.set_cpu_failed(state.ticket_id) + elif cpu_passed: + state.ost.set_cpu_passed(state.ticket_id) + state.ost.set_cpu_max_temp(state.ticket_id, temp=cpu_max_temp) # Disk checkboxes if any_disk_failures: @@ -1345,6 +1332,20 @@ def run_hw_tests(state): elif all_disk_tests_enabled and all_disks_passed: state.ost.set_disk_passed(state.ticket_id) + # Upload for review + if (ENABLED_UPLOAD_DATA + and DEBUG_MODE + and ask('Upload results for review?')): + try_and_print( + message='Saving debug reports...', + function=save_debug_reports, + state=state, global_vars=global_vars) + try_and_print( + message='Uploading Data...', + function=upload_logdir, + global_vars=global_vars, + reason='Review') + # Done sleep(1) if state.quick_mode: