Closed aenigma-es closed 11 months ago
You are welcome to add an entry to the CHANGELOG.md as well
Hmm the current code works fine on my machine while your patch provokes an exception
Traceback (most recent call last):
File "/home/phil/devel/00smartcard/readers/ChameleonUltra/ChameleonUltra.git/software/script/chameleon_cli_main.py", line 121, in exec_cmd
args_parse_result = args.parse_args(arg_list)
^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3.11/argparse.py", line 1881, in parse_args
args, argv = self.parse_known_args(args, namespace)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3.11/argparse.py", line 1914, in parse_known_args
namespace, args = self._parse_known_args(args, namespace)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3.11/argparse.py", line 2154, in _parse_known_args
self.error(_('the following arguments are required: %s') %
File "/home/phil/devel/00smartcard/readers/ChameleonUltra/ChameleonUltra.git/software/script/chameleon_utils.py", line 53, in error
raise ArgsParserError('%(prog)s: error: %(message)s\n' % args)
chameleon_utils.ArgsParserError: hw slot change: error: the following arguments are required: -s/--slot
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/home/phil/devel/00smartcard/readers/ChameleonUltra/ChameleonUltra.git/software/script/chameleon_cli_main.py", line 186, in <module>
ChameleonCLI().startCLI()
File "/home/phil/devel/00smartcard/readers/ChameleonUltra/ChameleonUltra.git/software/script/chameleon_cli_main.py", line 178, in startCLI
self.exec_cmd(cmd_str)
File "/home/phil/devel/00smartcard/readers/ChameleonUltra/ChameleonUltra.git/software/script/chameleon_cli_main.py", line 123, in exec_cmd
args.print_help()
File "/home/phil/devel/00smartcard/readers/ChameleonUltra/ChameleonUltra.git/software/script/chameleon_utils.py", line 91, in print_help
assert options[0].strip() == 'optional arguments:'
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
I think the text comes from the argparse
module. What is your versions of argparse and of python?
So the problem is caused by different argparse versions.
I'm using Python 3.9.2 and argparse 1.1 They are from a standard install of a Debian 11
$ python3
Python 3.9.2 (default, Feb 28 2021, 17:03:44)
[GCC 10.2.1 20210110] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import argparse
>>> print(argparse.__version__)
1.1
>>> exit()
Strange, I've python 3.11.6 and argparse 1.1 Let's get the code catch both variants...
I pushed a fix, does it work for you @aenigma-es ?
It's working perfectly. Thanks
When wrong arguments were used, the CLI would fail for an assert that was expecting a different text.
Changed: "options:" to "optional arguments:"