From 5cf2fa6f27f7b94e25874b155287abdbfa1c351a Mon Sep 17 00:00:00 2001 From: 2Shirt <2xShirt@gmail.com> Date: Wed, 26 Dec 2018 20:57:30 -0700 Subject: [PATCH] Added remaining osTicket sections --- .bin/Scripts/functions/hw_diags.py | 51 ++++++++++++++++++++++++++++-- 1 file changed, 48 insertions(+), 3 deletions(-) diff --git a/.bin/Scripts/functions/hw_diags.py b/.bin/Scripts/functions/hw_diags.py index 046a3cf8..26551f48 100644 --- a/.bin/Scripts/functions/hw_diags.py +++ b/.bin/Scripts/functions/hw_diags.py @@ -495,7 +495,7 @@ class State(): def __init__(self): self.cpu = None self.disks = [] - self.ost_integration = False + self.ost = osTicket(TESTS_CPU, TESTS_DISK) self.panes = {} self.quick_mode = False self.tests = OrderedDict({ @@ -520,6 +520,7 @@ class State(): 'Objects': [], }, }) + self.ticket_id = None def init(self): """Remove test objects, set log, and add devices.""" @@ -948,6 +949,10 @@ def run_hw_tests(state): """Run enabled hardware tests.""" print_standard('Scanning devices...') state.init() + tests_enabled = False + + # Disable osTicket Integration if in quick mode + state.ost.disabled |= state.quick_mode # Build Panes update_progress_pane(state) @@ -963,6 +968,8 @@ def run_hw_tests(state): COLORS['CLEAR'], QUICK_LABEL if state.quick_mode and 'NVMe' in k else '')) if v['Enabled']: + tests_enabled = True + # Create TestObj and track under both CpuObj/DiskObj and State if k in TESTS_CPU: test_obj = TestObj( @@ -976,6 +983,15 @@ def run_hw_tests(state): v['Objects'].append(test_obj) print_standard('') + # Bail if no tests selected + if not tests_enabled: + tmux_kill_pane(*state.panes.values()) + return + + # Get ticket_number + if not state.ost.disabled: + state.ticket_id = state.ost.get_ticket_number() + # Run disk safety checks (if necessary) _disk_tests_enabled = False for k in TESTS_DISK: @@ -993,6 +1009,9 @@ def run_hw_tests(state): f = v['Function'] for test_obj in v['Objects']: f(state, test_obj) + if k == TESTS_CPU[-1]: + # Last CPU test run, post CPU results + state.ost.post_device_results(state.cpu, state.ticket_id) except GenericAbort: # Cleanup tmux_kill_pane(*state.panes.values()) @@ -1011,14 +1030,40 @@ def run_hw_tests(state): # Update side pane update_progress_pane(state) - # Done + # Show results and determine if HDD checkbox needs updated + all_drives_passed = True + disk_failures = False show_results(state) + for disk in state.disks: + if disk.checkbox is None: + # Aborted/Unknown/etc + all_drives_passed = False + else: + all_drives_passed &= disk.checkbox + disk_failures |= not disk.checkbox + + # Post test results for disk + state.ost.post_device_results(disk, state.ticket_id) + + # Update checkbox if necessary + if disk_failures: + state.ost.set_disk_failed(state.ticket_id) + elif all_drives_passed: + state.ost.set_disk_passed(state.ticket_id) + + # Check for osTicket errors + if state.ost.errors: + print_warning('Errors encountered posting results to osTicket.') + print_standard(' ') + + # Done if state.quick_mode: pause('Press Enter to exit...') else: pause('Press Enter to return to main menu... ') # Cleanup + state.ost.disconnect(full=True) tmux_kill_pane(*state.panes.values()) def run_io_benchmark(state, test): @@ -1604,7 +1649,7 @@ def update_main_options(state, selection, main_options): main_options[5]['Enabled'] = False # Update state - state.ost_integration = main_options[3]['Enabled'] + state.ost.disabled = not main_options[3]['Enabled'] for opt in main_options[4:]: state.tests[opt['Base Name']]['Enabled'] = opt['Enabled']