Actions
Bug #3157
closedsuricatactl does not display proper usage note on Python3
Affected Versions:
Effort:
Difficulty:
Label:
Description
I'm currently looking to migrate the Debian package for Suricata to Python3, as Python2 will be removed from Debian in the next release.
I noticed that when using Python 3, simply running suricatactl
gives a not very helpful error message:
$ sudo suricatactl
Traceback (most recent call last):
File "/usr/bin/suricatactl", line 40, in <module>
sys.exit(main())
File "/usr/lib/python3/dist-packages/suricata/ctl/main.py", line 50, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'
Apparently there is a quirk in this aspect of argparse (see https://bugs.python.org/issue16308). A workaround that did it for me was replacing args.func(args)
with:
try:
func = args.func
except AttributeError:
parser.error("too few arguments")
func(args)
Result:
$ sudo suricatactl
usage: suricatactl [-h] {filestore} ...
suricatactl: error: too few arguments
This should work on both Python 2 and 3. I can submit a PR if you want.
Updated by Andreas Herz about 5 years ago
- Assignee set to Sascha Steinbiss
- Target version set to TBD
Sounds like a valid solution for me
Updated by Andreas Herz about 5 years ago
- Status changed from New to Closed
Updated by Andreas Herz about 5 years ago
- Target version changed from TBD to 5.0.0
Updated by Victor Julien about 5 years ago
- Assignee changed from Sascha Steinbiss to Shivani Bhardwaj
Actions