Added safety check for devices
This commit is contained in:
parent
62c9d82fd2
commit
1489ad4237
1 changed files with 53 additions and 8 deletions
|
|
@ -192,6 +192,37 @@ class State():
|
|||
self.devs.append(DevObj(dev['name']))
|
||||
|
||||
# Functions
|
||||
def check_dev_attributes(dev):
|
||||
"""Check if device should be tested and allow overrides."""
|
||||
needs_override = False
|
||||
print_standard(' {size:>6} ({tran}) {model} {serial}'.format(
|
||||
**dev.lsblk))
|
||||
|
||||
# General checks
|
||||
if not dev.nvme_attributes and not dev.smart_attributes:
|
||||
needs_override = True
|
||||
print_warning(
|
||||
' WARNING: No NVMe or SMART attributes available for: {}'.format(
|
||||
dev.path))
|
||||
|
||||
# NVMe checks
|
||||
# TODO check all tracked attributes and set dev.failing if needed
|
||||
|
||||
# SMART checks
|
||||
# TODO check all tracked attributes and set dev.failing if needed
|
||||
|
||||
# Ask for override if necessary
|
||||
if needs_override:
|
||||
if ask(' Run tests on this device anyway?'):
|
||||
# TODO Set override for this dev
|
||||
pass
|
||||
else:
|
||||
for v in dev.tests.values():
|
||||
v['Enabled'] = False
|
||||
v['Result'] = 'Skipped'
|
||||
v['Status'] = 'Skipped'
|
||||
print_standard('')
|
||||
|
||||
def generate_horizontal_graph(rates, oneline=False):
|
||||
"""Generate two-line horizontal graph from rates, returns str."""
|
||||
line_1 = ''
|
||||
|
|
@ -397,7 +428,7 @@ def run_hw_tests(state):
|
|||
"""Run enabled hardware tests."""
|
||||
# Run test(s)
|
||||
clear_screen()
|
||||
print('Tests:')
|
||||
print_info('Selected Tests:')
|
||||
for k, v in sorted(
|
||||
state.tests.items(),
|
||||
key=lambda kv: kv[1]['Order']):
|
||||
|
|
@ -407,7 +438,21 @@ def run_hw_tests(state):
|
|||
'Enabled' if v['Enabled'] else 'Disabled',
|
||||
COLORS['CLEAR'],
|
||||
QUICK_LABEL if state.quick_mode and 'NVMe' in k else ''))
|
||||
pause('\nPress Enter to return to main menu... ')
|
||||
print_standard('')
|
||||
|
||||
# Check devices if necessary
|
||||
if (state.tests['badblocks']['Enabled']
|
||||
or state.tests['I/O Benchmark']['Enabled']):
|
||||
print_info('Selected Disks:')
|
||||
for dev in state.devs:
|
||||
check_dev_attributes(dev)
|
||||
print_standard('')
|
||||
|
||||
# Run tests
|
||||
# TODO
|
||||
|
||||
# Done
|
||||
pause('Press Enter to return to main menu... ')
|
||||
|
||||
def run_keyboard_test():
|
||||
"""Run keyboard test."""
|
||||
|
|
|
|||
Loading…
Reference in a new issue