etingof / snmpsim

SNMP Simulator

Home Page:http://snmplabs.com/snmpsim/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

"--help"、“-h” can't work with current trunk

chengshuangliu opened this issue · comments

root@python-stack-server:~# snmpsim-command-responder -h
Traceback (most recent call last):
File "/usr/local/bin/snmpsim-command-responder", line 8, in
sys.exit(main())
File "/usr/local/lib/python3.5/dist-packages/snmpsim/commands/responder.py", line 401, in main
snmp_helper.print_usage(sys.stderr)
File "/usr/lib/python3.5/argparse.py", line 2362, in print_usage
self._print_message(self.format_usage(), file)
File "/usr/lib/python3.5/argparse.py", line 2328, in format_usage
return formatter.format_help()
File "/usr/lib/python3.5/argparse.py", line 287, in format_help
help = self._root_section.format_help()
File "/usr/lib/python3.5/argparse.py", line 217, in format_help
func(*args)
File "/usr/lib/python3.5/argparse.py", line 338, in _format_usage
assert ' '.join(opt_parts) == opt_usage
AssertionError

some code in argparse.py:
part_regexp = r'(.?)+|[.?]+|\S+'
opt_usage = format(optionals, groups)
pos_usage = format(positionals, groups)
opt_parts = _re.findall(part_regexp, opt_usage)
pos_parts = _re.findall(part_regexp, pos_usage)

error point :
assert ' '.join(opt_parts) == opt_usage
assert ' '.join(pos_parts) == pos_usage

reason:

the re "part_regexp " split args error when double "[[]]" in some string like "[--logging-method =<syslog|null|stderr|file|stdout[:args]>]]".

commented

Hi,
Please try with the latest version to see if this resolved or not.

snmpsim-command-responder -h 
usage: snmpsim-command-responder [-v] [-h] [--help] [--quiet] [--debug {io,dsp,msgproc,secmod,mibbuild,mibview,mibinstrum,acl,proxy,app,all}]
                                 [--debug-asn1 {none,encoder,decoder,all}] [--logging-method =<syslog|file|stdout|stderr|null[:args]>]]
                                 [--log-level {debug,info,error}] [--reporting-method =<null|fulljson|minimaljson[:args]>]] [--daemonize]
                                 [--process-user PROCESS_USER] [--process-group PROCESS_GROUP] [--pid-file <FILE>] [--cache-dir <DIR>]
                                 [--force-index-rebuild] [--validate-data] [--variation-modules-dir <DIR>]
                                 [--variation-module-options <module[=alias][:args]>] [--v3-only] [--transport-id-offset TRANSPORT_ID_OFFSET]
                                 [--max-var-binds MAX_VAR_BINDS] [--args-from-file <FILE>] [--v3-engine-id <HEX|auto>] [--v3-user <STRING>]
                                 [--v3-auth-key V3_AUTH_KEY] [--v3-auth-proto {MD5,SHA,SHA224,SHA256,SHA384,SHA512,NONE}]
                                 [--v3-priv-key V3_PRIV_KEY] [--v3-priv-proto {DES,3DES,AES,AES128,AES192,AES192BLMT,AES256,AES256BLMT,NONE}]
                                 [--v3-context-engine-id V3_CONTEXT_ENGINE_ID] [--v3-context-name V3_CONTEXT_NAME]
                                 [--agent-udpv4-endpoint <[X.X.X.X]:NNNNN>] [--agent-udpv6-endpoint <[X:X:..X]:NNNNN>] [--data-dir <DIR>]