]> git.ipfire.org Git - thirdparty/suricata.git/commitdiff
prscript: rework option logic 1405/head
authorEric Leblond <eric@regit.org>
Fri, 13 Mar 2015 08:55:27 +0000 (09:55 +0100)
committerVictor Julien <victor@inliniac.net>
Tue, 7 Apr 2015 09:03:53 +0000 (11:03 +0200)
Handle cleanly the case where user start docker handling command
without having the dependency installed. The help message does
now say:

```
  -d, --docker          use docker based testing
  -C, --create          create docker container (disabled)
  -s, --start           start docker container (disabled)
  -S, --stop            stop docker container (disabled)

You need to install Python docker module to enable docker container handling
options.
```

And running a disabled options says:

```
$ qa/prscript.py -s
You need to install python docker to use docker handling features.
```

qa/prscript.py

index 3fd3354d1b9e8ab7457abeca9fc8d38596dfd64b..4f401edde44b623aba6f938caa72b23895654c12 100755 (executable)
@@ -50,37 +50,47 @@ BASE_URI="https://buildbot.openinfosecfoundation.org/"
 GITHUB_BASE_URI = "https://api.github.com/repos/"
 GITHUB_MASTER_URI = "https://api.github.com/repos/inliniac/suricata/commits?sha=master"
 
-parser = argparse.ArgumentParser(prog='prscript', description='Script checking validity of branch before PR')
+if GOT_DOCKER:
+    parser = argparse.ArgumentParser(prog='prscript', description='Script checking validity of branch before PR')
+else:
+    parser = argparse.ArgumentParser(prog='prscript', description='Script checking validity of branch before PR',
+                                     epilog='You need to install Python docker module to enable docker container handling options.')
 parser.add_argument('-u', '--username', dest='username', help='github and buildbot user')
 parser.add_argument('-p', '--password', dest='password', help='buildbot password')
 parser.add_argument('-c', '--check', action='store_const', const=True, help='only check last build', default=False)
 parser.add_argument('-v', '--verbose', action='store_const', const=True, help='verbose output', default=False)
 parser.add_argument('--norebase', action='store_const', const=True, help='do not test if branch is in sync with master', default=False)
 parser.add_argument('-r', '--repository', dest='repository', default='suricata', help='name of suricata repository on github')
-parser.add_argument('-d', '--docker', action='store_const', const=True, help='use docker based testing', default=False)
 parser.add_argument('-l', '--local', action='store_const', const=True, help='local testing before github push', default=False)
 if GOT_NOTIFY:
     parser.add_argument('-n', '--notify', action='store_const', const=True, help='send desktop notification', default=False)
-if GOT_DOCKER:
-    parser.add_argument('-C', '--create', action='store_const', const=True, help='create docker container', default=False)
-    parser.add_argument('-s', '--start', action='store_const', const=True, help='start docker container', default=False)
-    parser.add_argument('-S', '--stop', action='store_const', const=True, help='stop docker container', default=False)
+
+docker_deps = ""
+if not GOT_DOCKER:
+    docker_deps = " (disabled)"
+parser.add_argument('-d', '--docker', action='store_const', const=True, help='use docker based testing', default=False)
+parser.add_argument('-C', '--create', action='store_const', const=True, help='create docker container' + docker_deps, default=False)
+parser.add_argument('-s', '--start', action='store_const', const=True, help='start docker container' + docker_deps, default=False)
+parser.add_argument('-S', '--stop', action='store_const', const=True, help='stop docker container' + docker_deps, default=False)
 parser.add_argument('branch', metavar='branch', help='github branch to build', nargs='?')
 args = parser.parse_args()
 username = args.username
 password = args.password
 cookie = None
 
+if args.create or args.start or args.stop:
+    if GOT_DOCKER:
+        args.docker = True
+        args.local = True
+    else:
+        print "You need to install python docker to use docker handling features."
+        sys.exit(-1)
+
 if not args.local:
     if not args.username:
         print "You need to specify a github username (-u option) for this mode (or use -l to disable)"
         sys.exit(-1)
 
-if GOT_DOCKER:
-    if args.create or args.start or args.stop:
-        args.docker = True
-        args.local = True
-
 if args.docker:
     BASE_URI="http://localhost:8010/"
     BUILDERS_LIST = ["gcc", "clang", "debug", "features", "profiling", "pcaps"]