Added osTicket checkbox sections
This commit is contained in:
parent
e9c0855f65
commit
b9d0527c52
1 changed files with 55 additions and 11 deletions
|
|
@ -35,6 +35,7 @@ BADBLOCKS_REGEX = re.compile(
|
|||
r'^Pass completed, (\d+) bad blocks found. .(\d+)/(\d+)/(\d+) errors',
|
||||
re.IGNORECASE,
|
||||
)
|
||||
CPU_MAX_TEMP = 0
|
||||
IO_GRAPH_WIDTH = 40
|
||||
IO_ALT_TEST_SIZE_FACTOR = 0.01
|
||||
IO_BLOCK_SIZE = 512 * 1024
|
||||
|
|
@ -732,6 +733,14 @@ def cpu_mprime_test(state, test_objects):
|
|||
test_cooling_obj.report.append(std.color_string('Temps', 'BLUE'))
|
||||
check_cooling_results(test_obj=test_cooling_obj, sensors=sensors)
|
||||
|
||||
# Post results to osTicket
|
||||
if not state.ost.disabled:
|
||||
CPU_MAX_TEMP = sensors.cpu_max_temp() # pylint: disable=invalid-name,redefined-outer-name,unused-variable
|
||||
state.ost.post_response(
|
||||
ost_build_report(state.cpu, 'CPU'),
|
||||
color='Diags FAIL' if state.cpu.any_test_failed() else 'Diags',
|
||||
)
|
||||
|
||||
# Cleanup
|
||||
state.update_progress_pane()
|
||||
sensors.stop_background_monitor()
|
||||
|
|
@ -1281,6 +1290,7 @@ def ost_convert_report(original_report, start_index):
|
|||
_hex = match.group('hex')
|
||||
_data = match.group('data')
|
||||
line = f'{_hex}/{_dec}: {_data}'
|
||||
line = line.replace('failed', 'FAILED')
|
||||
|
||||
# Skip empty lines
|
||||
if not line.strip():
|
||||
|
|
@ -1319,6 +1329,48 @@ def ost_post_disk_results(state):
|
|||
)
|
||||
|
||||
|
||||
def ost_update_checkboxes(state):
|
||||
"""Update osTicket checkboxes after confirmation."""
|
||||
cpu_tests_enabled = [data['Enabled'] for name, data in state.tests.items()
|
||||
if name.startswith('CPU')]
|
||||
disk_tests_enabled = [data['Enabled'] for name, data in state.tests.items()
|
||||
if name.startswith('Disk')]
|
||||
|
||||
# Bail if osTicket integration disabled
|
||||
if state.ost.disabled:
|
||||
return
|
||||
|
||||
# Bail if values not confirmed
|
||||
if not std.ask('Update osTicket checkboxes using the data above?'):
|
||||
return
|
||||
|
||||
# CPU max temp and pass/fail
|
||||
if any(cpu_tests_enabled):
|
||||
state.ost.set_cpu_max_temp(CPU_MAX_TEMP)
|
||||
if state.cpu.any_test_failed():
|
||||
state.ost.set_flag_failed('CPU')
|
||||
elif state.cpu.all_tests_passed():
|
||||
state.ost.set_flag_passed('CPU')
|
||||
|
||||
# Disk pass/fail (only if all disk tests were selected)
|
||||
if all(disk_tests_enabled) and len(disk_tests_enabled) == NUM_DISK_TESTS:
|
||||
all_disks_passed = True
|
||||
|
||||
# Check results for all disks
|
||||
for disk in state.disks:
|
||||
if disk.any_test_failed():
|
||||
all_disks_passed = False
|
||||
state.ost.set_flag_failed('Disk')
|
||||
break
|
||||
if not disk.all_tests_passed():
|
||||
all_disks_passed = False
|
||||
break
|
||||
|
||||
# All disks passed
|
||||
if all_disks_passed:
|
||||
state.ost.set_flag_passed('Disk')
|
||||
|
||||
|
||||
def print_countdown(proc, seconds):
|
||||
"""Print countdown to screen while proc is alive."""
|
||||
for i in range(seconds):
|
||||
|
|
@ -1346,7 +1398,6 @@ 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)
|
||||
|
|
@ -1397,16 +1448,6 @@ 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
|
||||
|
|
@ -1426,6 +1467,9 @@ def run_diags(state, menu, quick_mode=False):
|
|||
# Show results
|
||||
show_results(state)
|
||||
|
||||
# Update checkboxes
|
||||
ost_update_checkboxes(state)
|
||||
|
||||
# Done
|
||||
state.save_debug_reports()
|
||||
atexit.unregister(state.save_debug_reports)
|
||||
|
|
|
|||
Loading…
Reference in a new issue