From 5708497358a2be22be940da550191ca79c698e61 Mon Sep 17 00:00:00 2001 From: Longxiang Lyu <35479537+lolyu@users.noreply.github.com> Date: Tue, 22 Jun 2021 03:51:57 +0800 Subject: [PATCH] [show] fix `show version` (#1686) #### What I did Fix `NameError` from `show version`. ``` admin@str2-7050cx3-acs-02:~$ show version Traceback (most recent call last): File "/usr/local/bin/show", line 8, in sys.exit(cli()) File "/usr/local/lib/python3.7/dist-packages/click/core.py", line 764, in __call__ return self.main(*args, **kwargs) File "/usr/local/lib/python3.7/dist-packages/click/core.py", line 717, in main rv = self.invoke(ctx) File "/usr/local/lib/python3.7/dist-packages/click/core.py", line 1137, in invoke return _process_result(sub_ctx.command.invoke(sub_ctx)) File "/usr/local/lib/python3.7/dist-packages/click/core.py", line 956, in invoke return ctx.invoke(self.callback, **ctx.params) File "/usr/local/lib/python3.7/dist-packages/click/core.py", line 555, in invoke return callback(*args, **kwargs) File "/usr/local/lib/python3.7/dist-packages/show/main.py", line 960, in version chassis_info = platform.get_chassis_info() File "/usr/local/lib/python3.7/dist-packages/show/platform.py", line 27, in get_chassis_info platform_chassis = sonic_platform.platform.Platform().get_chassis() NameError: name 'sonic_platform' is not defined ``` #### How I did it Import `sonic_platform` before using `sonic_platform`. Signed-off-by: Longxiang Lyu --- show/platform.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/show/platform.py b/show/platform.py index 739ef5f476..94d1d8bd63 100644 --- a/show/platform.py +++ b/show/platform.py @@ -23,7 +23,7 @@ def get_chassis_info(): for k in required_keys: if chassis_info.get(k, '') in failed_vals: if platform_chassis is None: - import platform + import sonic_platform platform_chassis = sonic_platform.platform.Platform().get_chassis() try: chassis_info[k] = getattr(platform_chassis, "get_".format(k))()