Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
<!-- Please make sure you've read and understood our contributing guidelines: https://github.com/Azure/SONiC/blob/gh-pages/CONTRIBUTING.md ** Make sure all your commits include a signature generated with `git commit -s` ** If this is a bug fix, make sure your description includes "closes #xxxx", "fixes #xxxx" or "resolves #xxxx" so that GitHub automatically closes the related issue when the PR is merged. If you are adding/modifying/removing any command or utility script, please also make sure to add/modify/remove any unit tests from the tests directory as appropriate. If you are modifying or removing an existing 'show', 'config' or 'sonic-clear' subcommand, or you are adding a new subcommand, please make sure you also update the Command Line Reference Guide (doc/Command-Reference.md) to reflect your changes. Please provide the following information: --> #### What I did Catch the exception if a user passes in an invalid port name. #### How I did it Added a try/catch to catch the ValueError. #### How to verify it Run "show muxcable cableinfo [invalid port]". #### Previous command output (if the output of a command-line utility has changed) ``` crystalnet@ibr01:~$ show muxcable cableinfo all Traceback (most recent call last): File "/usr/local/bin/show", line 8, in <module> 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 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/click/decorators.py", line 64, in new_func return ctx.invoke(f, obj, *args, **kwargs) 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/muxcable.py", line 626, in cableinfo physical_port_list = platform_sfputil_helper.logical_port_name_to_physical_port_list(port) File "/usr/local/lib/python3.7/dist-packages/utilities_common/platform_sfputil_helper.py", line 53, in logical_port_name_to_physical_port_list return [int(port_name)] ValueError: invalid literal for int() with base 10: 'all' crystalnet@ibr01:~$ ``` #### New command output (if the output of a command-line utility has changed) ``` crystalnet@ibr01:~$ show muxcable cableinfo all Invalid port 'all' ERR: Unable to get a port on muxcable port crystalnet@ibr01:~$ ```
- Loading branch information