Post CPU/Disk results to osTicket
This commit is contained in:
parent
96b755be49
commit
9c12dacfb2
1 changed files with 36 additions and 11 deletions
|
|
@ -76,11 +76,11 @@ MENU_TOGGLES = (
|
|||
'osTicket Note (optional)',
|
||||
'Skip USB Benchmarks',
|
||||
)
|
||||
NUM_DISK_TESTS = sum([s for s in MENU_OPTIONS if s.startswith('Disk')])
|
||||
NUM_DISK_TESTS = len([s for s in MENU_OPTIONS if s.startswith('Disk')])
|
||||
PLATFORM = std.PLATFORM
|
||||
REGEX_BLOCK_GRAPH = re.compile(r'(▁|▂|▃|▄|▅|▆|▇|█)')
|
||||
REGEX_SMART_ATTRIBUTES = re.compile(
|
||||
r'^\s*(?P<decmial>\d+) / (?P<hex>\w\w): (?P<data>.*)$',
|
||||
r'^\s*(?P<decimal>\d+) / (?P<hex>\w\w): (?P<data>.*)$',
|
||||
)
|
||||
STATUS_COLORS = {
|
||||
'Passed': 'GREEN',
|
||||
|
|
@ -1225,7 +1225,7 @@ def ost_build_report(dev, dev_type):
|
|||
# Description
|
||||
report.append(dev.description)
|
||||
if hasattr(dev, 'ram_total'):
|
||||
report.append(f'{dev.ram_total} ({", ".join(dev.ramm_dimms)})')
|
||||
report.append(f'{dev.ram_total} ({", ".join(dev.ram_dimms)})')
|
||||
report.append('')
|
||||
|
||||
# Notes
|
||||
|
|
@ -1236,13 +1236,7 @@ def ost_build_report(dev, dev_type):
|
|||
|
||||
# Tests
|
||||
for name, test in dev.tests.items():
|
||||
# Name and result
|
||||
result = 'UNKNOWN'
|
||||
if test.failed:
|
||||
result = 'FAILED'
|
||||
elif test.passed:
|
||||
result = 'PASSED'
|
||||
report.append(f'{name} ({result})')
|
||||
report.append(f'{name} ({test.status})')
|
||||
|
||||
# Report
|
||||
if name == 'Disk Attributes' and dev.attributes:
|
||||
|
|
@ -1250,7 +1244,7 @@ def ost_build_report(dev, dev_type):
|
|||
ost_convert_report(dev.generate_attribute_report(), start_index=0),
|
||||
)
|
||||
else:
|
||||
report.extend(ost_convert_report(dev.report), start_index=1)
|
||||
report.extend(ost_convert_report(test.report, start_index=1))
|
||||
|
||||
# Spacer
|
||||
report.append('')
|
||||
|
|
@ -1308,6 +1302,23 @@ def ost_convert_report(original_report, start_index):
|
|||
return report
|
||||
|
||||
|
||||
def ost_post_disk_results(state):
|
||||
"""Post disk test results for all disks."""
|
||||
disk_tests_enabled = [data['Enabled'] for name, data in state.tests.items()
|
||||
if name.startswith('Disk')]
|
||||
|
||||
# Bail if no disk tests were run
|
||||
if not any(disk_tests_enabled) or state.ost.disabled:
|
||||
return
|
||||
|
||||
# Post disk results
|
||||
for disk in state.disks:
|
||||
state.ost.post_response(
|
||||
ost_build_report(disk, 'Disk'),
|
||||
color='Diags FAIL' if disk.any_test_failed() else 'Diags',
|
||||
)
|
||||
|
||||
|
||||
def print_countdown(proc, seconds):
|
||||
"""Print countdown to screen while proc is alive."""
|
||||
for i in range(seconds):
|
||||
|
|
@ -1335,6 +1346,7 @@ def print_countdown(proc, seconds):
|
|||
|
||||
|
||||
def run_diags(state, menu, quick_mode=False):
|
||||
# pylint: disable=too-many-branches
|
||||
"""Run selected diagnostics."""
|
||||
aborted = False
|
||||
atexit.register(state.save_debug_reports)
|
||||
|
|
@ -1385,6 +1397,16 @@ def run_diags(state, menu, quick_mode=False):
|
|||
aborted = True
|
||||
state.abort_testing()
|
||||
state.update_progress_pane()
|
||||
|
||||
# Post CPU results
|
||||
if name.startswith('CPU') and not state.ost.disabled:
|
||||
state.ost.post_response(
|
||||
ost_build_report(state.cpu, 'CPU'),
|
||||
color='Diags FAIL' if state.cpu.any_test_failed() else 'Diags',
|
||||
)
|
||||
|
||||
# Exit if aborted
|
||||
if aborted:
|
||||
break
|
||||
|
||||
# Run safety checks
|
||||
|
|
@ -1398,6 +1420,9 @@ def run_diags(state, menu, quick_mode=False):
|
|||
if test_obj.status == 'Pending':
|
||||
test_obj.set_status('Aborted')
|
||||
|
||||
# Post disk results
|
||||
ost_post_disk_results(state)
|
||||
|
||||
# Show results
|
||||
show_results(state)
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue