Avoid crash described in issue #39

This commit is contained in:
2Shirt 2018-09-12 16:15:15 -06:00
parent 83064d7c90
commit 56e354f124
Signed by: 2Shirt
GPG key ID: 152FAC923B0E132C

View file

@ -271,18 +271,21 @@ def run_badblocks():
print_standard('Done', timestamp=False) print_standard('Done', timestamp=False)
# Check results # Check results
with open(progress_file, 'r') as f: if os.path.exists(progress_file):
text = f.read() with open(progress_file, 'r') as f:
TESTS['badblocks']['Results'][name] = text text = f.read()
r = re.search(r'Pass completed.*0/0/0 errors', text) TESTS['badblocks']['Results'][name] = text
if r: r = re.search(r'Pass completed.*0/0/0 errors', text)
TESTS['badblocks']['Status'][name] = 'CS' if r:
else: TESTS['badblocks']['Status'][name] = 'CS'
TESTS['badblocks']['Status'][name] = 'NS' else:
TESTS['badblocks']['Status'][name] = 'NS'
# Move temp file # Move temp file
shutil.move(progress_file, '{}/badblocks-{}.log'.format( shutil.move(progress_file, '{}/badblocks-{}.log'.format(
global_vars['LogDir'], name)) global_vars['LogDir'], name))
else:
TESTS['badblocks']['Status'][name] = 'NS'
update_progress() update_progress()
# Done # Done