Project

General

Profile

Actions

Bug #3157

closed

suricatactl does not display proper usage note on Python3

Added by Sascha Steinbiss over 4 years ago. Updated over 4 years ago.

Status:
Closed
Priority:
Normal
Target version:
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.

Actions #1

Updated by Andreas Herz over 4 years ago

  • Assignee set to Sascha Steinbiss
  • Target version set to TBD

Sounds like a valid solution for me

Actions #3

Updated by Andreas Herz over 4 years ago

  • Target version changed from TBD to 5.0.0
Actions #4

Updated by Victor Julien over 4 years ago

  • Assignee changed from Sascha Steinbiss to Shivani Bhardwaj
Actions

Also available in: Atom PDF