]> git.ipfire.org Git - thirdparty/suricata.git/commitdiff
suricatactl: Make code compatible with Python 3
authorShivani Bhardwaj <shivanib134@gmail.com>
Sat, 16 Feb 2019 17:57:24 +0000 (23:27 +0530)
committerVictor Julien <victor@inliniac.net>
Sun, 24 Feb 2019 19:00:55 +0000 (20:00 +0100)
Call to suricatactl was failing with Python3 with the following error:
```
Traceback (most recent call last):
  File "bin/suricatactl", line 40, in <module>
    sys.exit(main())
  File "./suricata/ctl/main.py", line 50, in main
    args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'
```
Fix this by making it run with Py3 just like it does with Py2.

Closes redmine ticket #2793

python/suricata/ctl/filestore.py
python/suricata/ctl/main.py
python/suricata/ctl/test_filestore.py

index f9f804d34378f435126fc19850aa7c6debf2fc72..c0f101b36eb45690a0515e8b86bea9aacc8a15a6 100644 (file)
@@ -30,7 +30,6 @@ class InvalidAgeFormatError(Exception):
     pass
 
 def register_args(parser):
-
     parsers = parser.add_subparsers()
 
     prune_parser = parsers.add_parser("prune")
index 6a742adaf4d73b21743e9c4290adae711f661fad..1d09b900e5b5576361097df98aecbbff21c5ea3a 100644 (file)
@@ -46,5 +46,8 @@ def main():
     filestore.register_args(subparsers.add_parser("filestore"))
 
     args = parser.parse_args()
-
-    args.func(args)
+    try:
+        func = args.func
+    except AttributeError:
+        parser.error("too few arguments")
+    func(args)
index 26b107fd23e87c597f676bc069f5e3b5b448d1e3..0cb0dd08a956ea561e9ee89d0629b4fefcad5adc 100644 (file)
@@ -2,7 +2,7 @@ from __future__ import print_function
 
 import unittest
 
-import filestore
+from suricata.ctl import filestore
 
 class PruneTestCase(unittest.TestCase):