Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 1 addition & 6 deletions scripts/psushow
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@ from tabulate import tabulate

VERSION = '1.0'



def get_psu_status_list():
psu_status_list = []

Expand All @@ -23,7 +21,6 @@ def get_psu_status_list():
chassis_name = "chassis {}".format(chassis_num)
num_psus = db.get(db.STATE_DB, 'CHASSIS_INFO|{}'.format(chassis_name), 'psu_num')
if not num_psus:
print('Error: Failed to get the number of PSUs')
return None

for psu_idx, psu_key in enumerate(natsorted(db.keys(db.STATE_DB, "PSU_INFO|*")), start = 1):
Expand Down Expand Up @@ -67,7 +64,6 @@ def psu_status_show_table(index):
psu_status_list = get_psu_status_list()

if not psu_status_list:
print('Error: Failed to get PSU status')
return None

header = ['PSU', 'Model', 'Serial', 'HW Rev', 'Voltage (V)', 'Current (A)', 'Power (W)', 'Status', 'LED']
Expand Down Expand Up @@ -102,7 +98,6 @@ def psu_status_show_json(index):
psu_status_list = get_psu_status_list()

if not psu_status_list:
print('Error: Failed to get PSU status')
return None

if index > 0:
Expand Down Expand Up @@ -144,7 +139,7 @@ Examples:
ret = psu_status_show_table(psu_index)

if ret != 0:
print("Error: failed to get PSU status from state DB")
print("PSU not detected")
return 1

return 0
Expand Down
4 changes: 2 additions & 2 deletions tests/psushow_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ def test_status_table(self, capsys):
# Test trying to display a non-existent PSU
expected_output = '''\
Error: PSU 3 is not available. Number of supported PSUs: 2
Error: failed to get PSU status from state DB
PSU not detected
'''
for arg in ['-s', '--status']:
with mock.patch('sys.argv', ['psushow', arg, '-i', '3']):
Expand Down Expand Up @@ -196,7 +196,7 @@ def test_status_json(self, capsys):
# Test trying to display a non-existent PSU
expected_output = '''\
Error: PSU 3 is not available. Number of supported PSUs: 2
Error: failed to get PSU status from state DB
PSU not detected
'''
for arg in ['-j', '--json']:
with mock.patch('sys.argv', ['psushow', '-s', '-i', '3', arg]):
Expand Down
Loading