Added progress pane logic
This commit is contained in:
parent
4cadb913e8
commit
aa3b69f6fa
1 changed files with 51 additions and 4 deletions
|
|
@ -67,6 +67,17 @@ MENU_SETS = {
|
||||||
MENU_TOGGLES = (
|
MENU_TOGGLES = (
|
||||||
'Skip USB Benchmarks',
|
'Skip USB Benchmarks',
|
||||||
)
|
)
|
||||||
|
STATUS_COLORS = {
|
||||||
|
'Aborted': 'YELLOW',
|
||||||
|
'Denied': 'RED',
|
||||||
|
'ERROR': 'RED',
|
||||||
|
'FAIL': 'RED',
|
||||||
|
'N/A': 'YELLOW',
|
||||||
|
'PASS': 'GREEN',
|
||||||
|
'TimedOut': 'RED',
|
||||||
|
'Unknown': 'YELLOW',
|
||||||
|
'Working': 'YELLOW',
|
||||||
|
}
|
||||||
WK_LABEL_REGEX = re.compile(
|
WK_LABEL_REGEX = re.compile(
|
||||||
fr'{cfg.main.KIT_NAME_SHORT}_(LINUX|UFD)',
|
fr'{cfg.main.KIT_NAME_SHORT}_(LINUX|UFD)',
|
||||||
re.IGNORECASE,
|
re.IGNORECASE,
|
||||||
|
|
@ -145,6 +156,8 @@ class State():
|
||||||
|
|
||||||
def init_diags(self, menu):
|
def init_diags(self, menu):
|
||||||
"""Initialize diagnostic pass."""
|
"""Initialize diagnostic pass."""
|
||||||
|
std.print_info('Starting Hardware Diagnostics')
|
||||||
|
|
||||||
# Reset objects
|
# Reset objects
|
||||||
self.disks.clear()
|
self.disks.clear()
|
||||||
self.layout.clear()
|
self.layout.clear()
|
||||||
|
|
@ -164,7 +177,13 @@ class State():
|
||||||
keep_history=False,
|
keep_history=False,
|
||||||
timestamp=False,
|
timestamp=False,
|
||||||
)
|
)
|
||||||
std.print_info('Starting Hardware Diagnostics')
|
|
||||||
|
# Progress Pane
|
||||||
|
self.update_progress_pane()
|
||||||
|
tmux.respawn_pane(
|
||||||
|
pane_id=self.panes['Progress'],
|
||||||
|
watch_file=f'{self.log_dir}/progress.out',
|
||||||
|
)
|
||||||
|
|
||||||
# Add HW Objects
|
# Add HW Objects
|
||||||
self.cpu = hw_obj.CpuRam()
|
self.cpu = hw_obj.CpuRam()
|
||||||
|
|
@ -226,6 +245,32 @@ class State():
|
||||||
text=' ',
|
text=' ',
|
||||||
)
|
)
|
||||||
|
|
||||||
|
def update_progress_pane(self):
|
||||||
|
"""Update progress pane."""
|
||||||
|
report = []
|
||||||
|
width = cfg.hw.TMUX_SIDE_WIDTH
|
||||||
|
|
||||||
|
for name, details in self.tests.items():
|
||||||
|
if not details['Enabled']:
|
||||||
|
continue
|
||||||
|
|
||||||
|
# Add test details
|
||||||
|
report.append(std.color_string(name, 'BLUE'))
|
||||||
|
for test_obj in details['Objects']:
|
||||||
|
report.append(std.color_string(
|
||||||
|
[test_obj.label, f'{test_obj.status:>{width-len(test_obj.label)}}'],
|
||||||
|
[None, STATUS_COLORS.get(test_obj.status, None)],
|
||||||
|
sep='',
|
||||||
|
))
|
||||||
|
|
||||||
|
# Add spacer
|
||||||
|
report.append(' ')
|
||||||
|
|
||||||
|
# Write to progress file
|
||||||
|
out_path = pathlib.Path(f'{self.log_dir}/progress.out')
|
||||||
|
with open(out_path, 'w') as _f:
|
||||||
|
_f.write('\n'.join(report))
|
||||||
|
|
||||||
def update_top_pane(self, text):
|
def update_top_pane(self, text):
|
||||||
"""Update top pane with text."""
|
"""Update top pane with text."""
|
||||||
tmux.respawn_pane(self.panes['Top'], text=f'{self.top_text}\n{text}')
|
tmux.respawn_pane(self.panes['Top'], text=f'{self.top_text}\n{text}')
|
||||||
|
|
@ -391,6 +436,7 @@ def cpu_mprime_test(state, test_objects):
|
||||||
sensors.start_background_monitor(sensors_out)
|
sensors.start_background_monitor(sensors_out)
|
||||||
|
|
||||||
# Create monitor and worker panes
|
# Create monitor and worker panes
|
||||||
|
state.update_progress_pane()
|
||||||
state.panes['Prime95'] = tmux.split_window(
|
state.panes['Prime95'] = tmux.split_window(
|
||||||
lines=10, vertical=True, watch_file=prime_log)
|
lines=10, vertical=True, watch_file=prime_log)
|
||||||
state.panes['Temps'] = tmux.split_window(
|
state.panes['Temps'] = tmux.split_window(
|
||||||
|
|
@ -443,6 +489,7 @@ def cpu_mprime_test(state, test_objects):
|
||||||
check_cooling_results(test_obj=test_cooling_obj, sensors=sensors)
|
check_cooling_results(test_obj=test_cooling_obj, sensors=sensors)
|
||||||
|
|
||||||
# Cleanup
|
# Cleanup
|
||||||
|
state.update_progress_pane()
|
||||||
sensors.stop_background_monitor()
|
sensors.stop_background_monitor()
|
||||||
state.panes.pop('Current', None)
|
state.panes.pop('Current', None)
|
||||||
tmux.kill_pane(state.panes.pop('Prime95', None))
|
tmux.kill_pane(state.panes.pop('Prime95', None))
|
||||||
|
|
@ -613,14 +660,14 @@ def main():
|
||||||
screensaver('pipes')
|
screensaver('pipes')
|
||||||
|
|
||||||
# Quit
|
# Quit
|
||||||
if 'Quit' in selection:
|
if 'Reboot' in selection:
|
||||||
break
|
|
||||||
elif 'Reboot' in selection:
|
|
||||||
cmd = ['/usr/local/bin/wk-power-command', 'reboot']
|
cmd = ['/usr/local/bin/wk-power-command', 'reboot']
|
||||||
exe.run_program(cmd, check=False)
|
exe.run_program(cmd, check=False)
|
||||||
elif 'Power Off' in selection:
|
elif 'Power Off' in selection:
|
||||||
cmd = ['/usr/local/bin/wk-power-command', 'poweroff']
|
cmd = ['/usr/local/bin/wk-power-command', 'poweroff']
|
||||||
exe.run_program(cmd, check=False)
|
exe.run_program(cmd, check=False)
|
||||||
|
elif 'Quit' in selection:
|
||||||
|
break
|
||||||
|
|
||||||
# Start diagnostics
|
# Start diagnostics
|
||||||
if 'Start' in selection:
|
if 'Start' in selection:
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue