diff --git a/.bin/Scripts/functions/hw_diags.py b/.bin/Scripts/functions/hw_diags.py index cd7c4303..79607b03 100644 --- a/.bin/Scripts/functions/hw_diags.py +++ b/.bin/Scripts/functions/hw_diags.py @@ -491,6 +491,8 @@ class State(): def init(self): """Remove test objects, set log, and add devices.""" self.disks = [] + self.ticket_id = None + self.ticket_name = None for k, v in self.tests.items(): v['Objects'] = [] @@ -533,6 +535,15 @@ class State(): self.tmux_layout = TMUX_LAYOUT.copy() start_thread(fix_tmux_panes_loop, args=[self]) + def set_top_pane_text(self, text): + """Set top pane text using TOP_PANE_TEXT and provided text.""" + ticket_details = '' + if self.ticket_id and self.ticket_name: + ticket_details = '#{} {}'.format(self.ticket_id, self.ticket_name) + tmux_update_pane( + self.panes['Top'], + text='{} {}\n{}'.format(TOP_PANE_TEXT, ticket_details, text)) + class TestObj(): """Object to track test data.""" @@ -875,10 +886,7 @@ def run_badblocks_test(state, test): update_progress_pane(state) # Update tmux layout - tmux_update_pane( - state.panes['Top'], - text='{}\n{}'.format( - TOP_PANE_TEXT, dev.description)) + state.set_top_pane_text(dev.description) # Create monitor pane test.badblocks_out = '{}/badblocks_{}.out'.format( @@ -1124,10 +1132,7 @@ def run_io_benchmark(state, test): update_progress_pane(state) # Update tmux layout - tmux_update_pane( - state.panes['Top'], - text='{}\n{}'.format( - TOP_PANE_TEXT, dev.description)) + state.set_top_pane_text(dev.description) state.tmux_layout['Current'] = {'y': 15, 'Check': True} # Create monitor pane @@ -1286,9 +1291,7 @@ def run_mprime_test(state, test): test.thermal_abort = False # Update tmux layout - tmux_update_pane( - state.panes['Top'], - text='{}\n{}'.format(TOP_PANE_TEXT, dev.name)) + state.set_top_pane_text(dev.name) # Start live sensor monitor test.sensors_out = '{}/sensors.out'.format(global_vars['TmpDir']) @@ -1501,10 +1504,7 @@ def run_nvme_smart_tests(state, test, update_mode=False): update_progress_pane(state) # Update tmux layout - tmux_update_pane( - state.panes['Top'], - text='{}\n{}'.format( - TOP_PANE_TEXT, dev.description)) + state.set_top_pane_text(dev.description) # SMART short self-test if dev.smart_attributes and not (state.quick_mode or update_mode): @@ -1643,15 +1643,7 @@ def show_report(report, log_report=False): def show_results(state): """Show results for all tests.""" clear_screen() - if state.ticket_id and state.ticket_name: - tmux_update_pane( - state.panes['Top'], - text='{}\nResults for #{} {}'.format( - TOP_PANE_TEXT, state.ticket_id, state.ticket_name)) - else: - tmux_update_pane( - state.panes['Top'], - text='{}\nResults'.format(TOP_PANE_TEXT)) + state.set_top_pane_text('Results') # CPU tests _enabled = False