diff options
| author | Jeff Lane <jeffrey.lane@canonical.com> | 2014-09-10 18:23:02 -0400 |
|---|---|---|
| committer | Jeff Lane <jeffrey.lane@canonical.com> | 2014-09-10 18:23:02 -0400 |
| commit | 9241f99095bf2d9187f41c10674eaae0d3aeff65 (patch) | |
| tree | d6347c9a3ca1312f2e9095f3c3c14daec62b68f1 /bin | |
| parent | f85454f622df5d152dbb38f1fbc367dd07ae34b9 (diff) | |
fixed a bug that would cause an IndexError when polling the SMART log on a HDD that has never had tests run before
Diffstat (limited to 'bin')
| -rwxr-xr-x | bin/disk_smart | 18 |
1 files changed, 11 insertions, 7 deletions
diff --git a/bin/disk_smart b/bin/disk_smart index 3545700..8d61969 100755 --- a/bin/disk_smart +++ b/bin/disk_smart @@ -125,6 +125,7 @@ def get_smart_entries(disk, type='selftest'): # Get lengths from header line = stdout.readline().decode() if not line.startswith('Num'): + entries.append('No entries found in log yet') return entries columns = ['number', 'description', 'status', 'remaining', 'lifetime', 'lba'] @@ -215,13 +216,16 @@ def main(): time.sleep(args.sleep) current_entries = get_smart_entries(disk) - logging.debug('%s %s %s %s' % (current_entries[0]['number'], - current_entries[0]['description'], - current_entries[0]['status'], - current_entries[0]['remaining'])) - if current_entries != previous_entries \ - and current_entries[0]["status"] != 'Self-test routine in progress': - break + if type(current_entries[0]) is str: + logging.debug(current_entries[0]) + else: + logging.debug('%s %s %s %s' % (current_entries[0]['number'], + current_entries[0]['description'], + current_entries[0]['status'], + current_entries[0]['remaining'])) + if current_entries != previous_entries \ + and current_entries[0]["status"] != 'Self-test routine in progress': + break if args.timeout is not None: if args.timeout <= 0: |
