Avoid crash during SMART self-test

This commit is contained in:
2Shirt 2020-01-28 18:09:33 -07:00
parent fe50ce8994
commit cc8c0992f6
Signed by: 2Shirt
GPG key ID: 152FAC923B0E132C

View file

@ -368,9 +368,13 @@ class Disk(BaseObj):
try:
details = self.smartctl['ata_smart_data']['self_test']
except (KeyError, TypeError):
# Assuming disk lacks SMART support, ignore and return empty dict.
# Assuming disk lacks SMART support, ignore and return nearly empty dict.
pass
# Ensure status is present even if empty
if 'status' not in details:
details['status'] = {}
# Done
return details