From d37923a31cfc7471ac37e2e98efb7b900db7383c Mon Sep 17 00:00:00 2001 From: 2Shirt <2xShirt@gmail.com> Date: Thu, 20 Dec 2018 17:26:27 -0700 Subject: [PATCH 1/5] Bugfix: typo --- .bin/Scripts/settings/launchers.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.bin/Scripts/settings/launchers.py b/.bin/Scripts/settings/launchers.py index 43e8e158..5135ec08 100644 --- a/.bin/Scripts/settings/launchers.py +++ b/.bin/Scripts/settings/launchers.py @@ -212,6 +212,7 @@ LAUNCHERS = { r')', ], }, + }, r'Diagnostics\Extras': { 'AIDA64': { 'L_TYPE': 'Executable', @@ -556,8 +557,7 @@ LAUNCHERS = { 'L_ITEM': 'IObitUninstallerPortable.exe', }, }, - }, -} + } if __name__ == '__main__': print("This file is not meant to be called directly.") From 6d9f50629cff3e4ad60ce59abbc4edfa424229e6 Mon Sep 17 00:00:00 2001 From: 2Shirt <2xShirt@gmail.com> Date: Sat, 22 Dec 2018 17:55:49 -0700 Subject: [PATCH 2/5] Reworked status/color sections --- .bin/Scripts/functions/hw_diags.py | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/.bin/Scripts/functions/hw_diags.py b/.bin/Scripts/functions/hw_diags.py index 9f10f997..3642f49c 100644 --- a/.bin/Scripts/functions/hw_diags.py +++ b/.bin/Scripts/functions/hw_diags.py @@ -65,6 +65,11 @@ KEY_NVME = 'nvme_smart_health_information_log' KEY_SMART = 'ata_smart_attributes' QUICK_LABEL = '{YELLOW}(Quick){CLEAR}'.format(**COLORS) SIDE_PANE_WIDTH = 20 +STATUSES = { + 'RED': ['Denied', 'ERROR', 'NS', 'OVERRIDE', 'TimedOut'], + 'YELLOW': ['Aborted', 'N/A', 'Skipped', 'Unknown', 'Working'], + 'GREEN': ['CS'], +} TESTS_CPU = ['Prime95'] TESTS_DISK = [ 'I/O Benchmark', @@ -78,7 +83,10 @@ TMUX_LAYOUT = OrderedDict({ 'Progress': {'x': SIDE_PANE_WIDTH, 'Check': True}, }) -# Error Classe +# Regex +REGEX_ERROR_STATUS = re.compile('|'.join(STATUSES['RED'])) + +# Error Classes class DeviceTooSmallError(Exception): pass @@ -566,7 +574,8 @@ class TestObj(): def update_status(self, new_status=None): """Update status strings.""" - if self.disabled or re.search(r'ERROR|OVERRIDE', self.status): + if self.disabled or REGEX_ERROR_STATUS.search(self.status): + # Don't update error statuses if test is enabled return if new_status: self.status = build_status_string( @@ -603,12 +612,9 @@ def build_outer_panes(state): def build_status_string(label, status, info_label=False): """Build status string with appropriate colors.""" status_color = COLORS['CLEAR'] - if status in ['Denied', 'ERROR', 'NS', 'OVERRIDE', 'TimedOut']: - status_color = COLORS['RED'] - elif status in ['Aborted', 'N/A', 'Skipped', 'Unknown', 'Working']: - status_color = COLORS['YELLOW'] - elif status in ['CS']: - status_color = COLORS['GREEN'] + for k, v in STATUSES.items(): + if status in v: + status_color = COLORS[k] return '{l_c}{l}{CLEAR}{s_c}{s:>{s_w}}{CLEAR}'.format( l_c=COLORS['BLUE'] if info_label else '', From c15eb85a5e46c881c4d4ca9b0e821cf1cb3aafc2 Mon Sep 17 00:00:00 2001 From: 2Shirt <2xShirt@gmail.com> Date: Sat, 22 Dec 2018 18:07:06 -0700 Subject: [PATCH 3/5] Removed unused get_status_color and Skipped status --- .bin/Scripts/functions/hw_diags.py | 13 +------------ 1 file changed, 1 insertion(+), 12 deletions(-) diff --git a/.bin/Scripts/functions/hw_diags.py b/.bin/Scripts/functions/hw_diags.py index 3642f49c..c5002882 100644 --- a/.bin/Scripts/functions/hw_diags.py +++ b/.bin/Scripts/functions/hw_diags.py @@ -67,7 +67,7 @@ QUICK_LABEL = '{YELLOW}(Quick){CLEAR}'.format(**COLORS) SIDE_PANE_WIDTH = 20 STATUSES = { 'RED': ['Denied', 'ERROR', 'NS', 'OVERRIDE', 'TimedOut'], - 'YELLOW': ['Aborted', 'N/A', 'Skipped', 'Unknown', 'Working'], + 'YELLOW': ['Aborted', 'N/A', 'Unknown', 'Working'], 'GREEN': ['CS'], } TESTS_CPU = ['Prime95'] @@ -732,17 +732,6 @@ def get_read_rate(s): real_rate = convert_to_bytes(human_rate) return real_rate -def get_status_color(s): - """Get color based on status, returns str.""" - color = COLORS['CLEAR'] - if s in ['Denied', 'ERROR', 'NS', 'OVERRIDE']: - color = COLORS['RED'] - elif s in ['Aborted', 'N/A', 'Unknown', 'Working', 'Skipped']: - color = COLORS['YELLOW'] - elif s in ['CS']: - color = COLORS['GREEN'] - return color - def menu_diags(state, args): """Main menu to select and run HW tests.""" args = [a.lower() for a in args] From 6e37736146e6c97008e324f2b4d4df647984242e Mon Sep 17 00:00:00 2001 From: 2Shirt <2xShirt@gmail.com> Date: Sun, 23 Dec 2018 17:15:50 -0700 Subject: [PATCH 4/5] Only save attributes to log during show_results() --- .bin/Scripts/functions/hw_diags.py | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/.bin/Scripts/functions/hw_diags.py b/.bin/Scripts/functions/hw_diags.py index c5002882..5e9e712b 100644 --- a/.bin/Scripts/functions/hw_diags.py +++ b/.bin/Scripts/functions/hw_diags.py @@ -242,7 +242,9 @@ class DiskObj(): print_standard(' (Have you tried swapping the disk cable?)') else: # Override? - show_report(self.generate_attribute_report(description=True)) + show_report( + self.generate_attribute_report(description=True), + log_report=True) print_warning(' {} error(s) detected.'.format(attr_type)) if override_disabled: print_standard('Tests disabled for this device') @@ -1448,8 +1450,6 @@ def run_nvme_smart_tests(state, test): # Show attributes clear_screen() - print_info('Device ({})'.format(test.dev.name)) - print_standard(' {}'.format(test.dev.description)) show_report(test.dev.generate_attribute_report()) print_standard(' ') @@ -1537,11 +1537,12 @@ def secret_screensaver(screensaver=None): raise Exception('Invalid screensaver') run_program(cmd, check=False, pipe=False) -def show_report(report): - """Show report on screen and save to log w/out color.""" +def show_report(report, log_report=False): + """Show report on screen and optionally save to log w/out color.""" for line in report: print(line) - print_log(strip_colors(line)) + if log_report: + print_log(strip_colors(line)) def show_results(state): """Show results for all tests.""" @@ -1556,7 +1557,7 @@ def show_results(state): _enabled |= state.tests[k]['Enabled'] if _enabled: print_success('CPU:'.format(k)) - show_report(state.cpu.generate_cpu_report()) + show_report(state.cpu.generate_cpu_report(), log_report=True) print_standard(' ') # Disk tests @@ -1567,7 +1568,7 @@ def show_results(state): print_success('Disk{}:'.format( '' if len(state.disks) == 1 else 's')) for disk in state.disks: - show_report(disk.generate_disk_report()) + show_report(disk.generate_disk_report(), log_report=True) print_standard(' ') def update_main_options(state, selection, main_options): From 96d34ceb5038549ffa09451f46a95b3a4598c98e Mon Sep 17 00:00:00 2001 From: 2Shirt <2xShirt@gmail.com> Date: Sun, 23 Dec 2018 17:33:16 -0700 Subject: [PATCH 5/5] Fix SMART short-test results section * OVERRIDE status reduced to yellow/warning * Allows it to be elevated to NS or TimedOut * Only disable other disk tests on test.failed * OVERRIDE doesn't work if based on test.passed for this test --- .bin/Scripts/functions/hw_diags.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.bin/Scripts/functions/hw_diags.py b/.bin/Scripts/functions/hw_diags.py index 5e9e712b..cbfd4377 100644 --- a/.bin/Scripts/functions/hw_diags.py +++ b/.bin/Scripts/functions/hw_diags.py @@ -66,8 +66,8 @@ KEY_SMART = 'ata_smart_attributes' QUICK_LABEL = '{YELLOW}(Quick){CLEAR}'.format(**COLORS) SIDE_PANE_WIDTH = 20 STATUSES = { - 'RED': ['Denied', 'ERROR', 'NS', 'OVERRIDE', 'TimedOut'], - 'YELLOW': ['Aborted', 'N/A', 'Unknown', 'Working'], + 'RED': ['Denied', 'ERROR', 'NS', 'TimedOut'], + 'YELLOW': ['Aborted', 'N/A', 'OVERRIDE', 'Unknown', 'Working'], 'GREEN': ['CS'], } TESTS_CPU = ['Prime95'] @@ -1513,7 +1513,7 @@ def run_nvme_smart_tests(state, test): test.update_status('TimedOut') # Disable other drive tests if necessary - if not test.passed: + if test.failed: for t in ['badblocks', 'I/O Benchmark']: test.dev.disable_test(t, 'Denied')