summaryrefslogtreecommitdiff
diff options
authorRod Smith <rod.smith@canonical.com>2014-10-02 10:21:05 -0400
committerRod Smith <rod.smith@canonical.com>2014-10-02 10:21:05 -0400
commit8a380e6cc3c203d6c3ddefa0311015e614103569 (patch)
tree4bf304cd4c86c039541d4c5b8c8ac6b791d6a85d
parenta1a480a4672eb310b0493fcab47f0878f3438d6d (diff)
Made changes recommended by Daniel Manrique
-rwxr-xr-xbin/disk_smart24
1 files changed, 13 insertions, 11 deletions
diff --git a/bin/disk_smart b/bin/disk_smart
index 936a926..3606e49 100755
--- a/bin/disk_smart
+++ b/bin/disk_smart
@@ -158,17 +158,19 @@ def get_smart_entries(disk, type='selftest'):
# output, False if such a message is not found. In the former case,
# the in-progress message entries are logged.
def in_progress(current_entries):
- ret_val = False
- for entry in current_entries:
- if not isinstance(entry, str):
- if entry['status'] == 'Self-test routine in progress':
- logging.debug('%s %s %s %s' % (entry['number'],
- entry['description'],
- entry['status'],
- entry['remaining']))
- ret_val = True
- break
- return ret_val
+ statuses = [entry for entry in current_entries
+ if isinstance(entry, dict)
+ and 'status' in entry
+ and entry['status'] == 'Self-test routine in progress']
+ if statuses:
+ for entry in statuses:
+ logging.debug('%s %s %s %s' % (entry['number'],
+ entry['description'],
+ entry['status'],
+ entry['remaining']))
+ return True
+ else:
+ return False
# Wait for SMART test to complete; no return value.