Skip to content

Commit 75d233f

Browse files
[system-health] Fix issue: show system-health CLI crashes (#2635)
- What I did Fix issue: show system-health CLI crashes root@switch:/home/admin# show system-health summary Traceback (most recent call last): File "/usr/local/bin/show", line 8, in <module> sys.exit(cli()) File "/usr/local/lib/python3.9/dist-packages/click/core.py", line 764, in __call__ return self.main(*args, **kwargs) File "/usr/local/lib/python3.9/dist-packages/click/core.py", line 717, in main rv = self.invoke(ctx) File "/usr/local/lib/python3.9/dist-packages/click/core.py", line 1137, in invoke return _process_result(sub_ctx.command.invoke(sub_ctx)) File "/usr/local/lib/python3.9/dist-packages/click/core.py", line 1137, in invoke return _process_result(sub_ctx.command.invoke(sub_ctx)) File "/usr/local/lib/python3.9/dist-packages/click/core.py", line 956, in invoke return ctx.invoke(self.callback, **ctx.params) File "/usr/local/lib/python3.9/dist-packages/click/core.py", line 555, in invoke return callback(*args, **kwargs) File "/usr/local/lib/python3.9/dist-packages/show/system_health.py", line 113, in summary _, chassis, stat = get_system_health_status() File "/usr/local/lib/python3.9/dist-packages/show/system_health.py", line 10, in get_system_health_status if os.environ["UTILITIES_UNIT_TESTING"] == "1": File "/usr/lib/python3.9/os.py", line 679, in __getitem__ raise KeyError(key) from None KeyError: 'UTILITIES_UNIT_TESTING' - How I did it Use dict.get instead of [] operator. - How to verify it Manual test
1 parent 5782da4 commit 75d233f

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

show/system_health.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88

99
def get_system_health_status():
10-
if os.environ["UTILITIES_UNIT_TESTING"] == "1":
10+
if os.environ.get("UTILITIES_UNIT_TESTING") == "1":
1111
modules_path = os.path.join(os.path.dirname(__file__), "..")
1212
sys.path.insert(0, modules_path)
1313
from tests.system_health_test import MockerManager

0 commit comments

Comments
 (0)