Skip to content

Commit

Permalink
detect: Don't add empty lists
Browse files Browse the repository at this point in the history
If we don't have any areca controller, areca.detect() return an empty list.
It was then added to hrdw by an append.

This commit does :
- return None instead of an empty list if no controller got detected
- filter-out all None items out of the hdrw list
- makes a one liner to append areca into hrdw

Signed-off-by: Erwan Velu <e.velu@criteo.com>
  • Loading branch information
ErwanAliasr1 committed Sep 18, 2020
1 parent ef1cf28 commit f6a942a
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
7 changes: 6 additions & 1 deletion hardware/areca.py
Original file line number Diff line number Diff line change
Expand Up @@ -190,4 +190,9 @@ def detect():
hwlist.append(('areca', "disk%d" % disk_number, info,
disk_info_out[info]))

return hwlist
if len(hwlist):
return hwlist

# If we dont't detect any areca controller, return None
# This avoid having empty lists
return None
5 changes: 3 additions & 2 deletions hardware/detect.py
Original file line number Diff line number Diff line change
Expand Up @@ -927,8 +927,7 @@ def main():
args = parse_args(sys.argv[1:])

hrdw = []
areca_hrdw = areca.detect()
hrdw.append(areca_hrdw)
hrdw.append(areca.detect())
detect_hpa(hrdw)
detect_megacli(hrdw)
detect_disks(hrdw)
Expand All @@ -955,6 +954,8 @@ def main():

hrdw = clean_tuples(hrdw)

hrdw = list(filter(None, hrdw))

if args.human:
pprint.pprint(hrdw)
else:
Expand Down

0 comments on commit f6a942a

Please sign in to comment.