Fixed status updates

This commit is contained in:
2Shirt 2018-12-10 16:57:43 -07:00
parent bb93386fa0
commit a00105f718
Signed by: 2Shirt
GPG key ID: 152FAC923B0E132C

View file

@ -214,10 +214,10 @@ class State():
}) })
def init(self): def init(self):
"""Set log and add devices.""" """Remove test objects, set log, and add devices."""
self.disks = [] self.disks = []
for k in ['Result', 'Started', 'Status']: for k, v in self.tests.items():
self.tests['Prime95'][k] = False if k == 'Started' else '' v['Objects'] = []
# Update LogDir # Update LogDir
if not self.quick_mode: if not self.quick_mode:
@ -596,7 +596,7 @@ def run_hw_tests(state):
v['Objects'].append(test_obj) v['Objects'].append(test_obj)
elif k in TESTS_DISK: elif k in TESTS_DISK:
for disk in state.disks: for disk in state.disks:
test_obj = TestObj(dev=k) test_obj = TestObj(dev=k, label=disk.name)
disk.tests[k] = test_obj disk.tests[k] = test_obj
v['Objects'].append(test_obj) v['Objects'].append(test_obj)
print_standard('') print_standard('')
@ -705,7 +705,7 @@ def run_mprime_test(state, test):
except KeyboardInterrupt: except KeyboardInterrupt:
# Catch CTRL+C # Catch CTRL+C
test.aborted = True test.aborted = True
test.status = 'Aborted' test.update_status('Aborted')
print_warning('\nAborted.') print_warning('\nAborted.')
update_progress_pane(state) update_progress_pane(state)
@ -757,23 +757,23 @@ def run_mprime_test(state, test):
if log == 'results.txt': if log == 'results.txt':
if re.search(r'(error|fail)', _data, re.IGNORECASE): if re.search(r'(error|fail)', _data, re.IGNORECASE):
test.failed = True test.failed = True
test.status = 'NS' test.update_status('NS')
# prime.log: CS check # prime.log: CS check
if log == 'prime.log': if log == 'prime.log':
if re.search( if re.search(
r'completed.*0 errors, 0 warnings', _data, re.IGNORECASE): r'completed.*0 errors, 0 warnings', _data, re.IGNORECASE):
test.passed = True test.passed = True
test.status = 'CS' test.update_status('CS')
elif re.search( elif re.search(
r'completed.*\d+ errors, \d+ warnings', _data, re.IGNORECASE): r'completed.*\d+ errors, \d+ warnings', _data, re.IGNORECASE):
# If the first re.search does not match and this one does then # If the first re.search does not match and this one does then
# that means that either errors or warnings, or both, are non-zero # that means that either errors or warnings, or both, are non-zero
test.failed = True test.failed = True
test.passed = False test.passed = False
test.status = 'NS' test.update_status('NS')
if not (test.aborted or test.failed or test.passed): if not (test.aborted or test.failed or test.passed):
test.status = 'Unknown' test.update_status('Unknown')
# Done # Done
update_progress_pane(state) update_progress_pane(state)
@ -910,19 +910,23 @@ def update_io_progress(percent, rate, progress_file):
def update_progress_pane(state): def update_progress_pane(state):
"""Update progress file for side pane.""" """Update progress file for side pane."""
output = [] output = []
# Prime95
output.append(state.tests['Prime95']['Status'])
output.append(' ')
# Disks
for k, v in state.tests.items(): for k, v in state.tests.items():
if 'Prime95' not in k and v['Enabled']: # Skip disabled sections
output.append('{BLUE}{test_name}{CLEAR}'.format( if not v['Enabled']:
test_name=k, **COLORS)) continue
for disk in state.disks:
output.append(disk.tests[k]['Status']) # Add section name
output.append(' ') if k != 'Prime95':
output.append('{BLUE}{name}{CLEAR}'.format(name=k, **COLORS))
if 'SMART' in k and state.quick_mode:
output.append(' {YELLOW}(Quick Check){CLEAR}'.format(**COLORS))
# Add status from test object(s)
for test in v['Objects']:
output.append(test.status)
# Add spacer before next section
output.append(' ')
# Add line-endings # Add line-endings
output = ['{}\n'.format(line) for line in output] output = ['{}\n'.format(line) for line in output]