]> git.apps.os.sepia.ceph.com Git - teuthology.git/commitdiff
Enable reporting of single jobs
authorZack Cerza <zack@cerza.org>
Thu, 12 Dec 2013 22:54:56 +0000 (16:54 -0600)
committerZack Cerza <zack@cerza.org>
Thu, 12 Dec 2013 23:00:43 +0000 (17:00 -0600)
(also switch to docopt)

Signed-off-by: Zack Cerza <zack.cerza@inktank.com>
scripts/report.py
teuthology/report.py

index 394f6153ac37e2eb219578f974e0bf76b0296dd7..c649c4d6d89fbd44fc3f4610bf2141e6cab3db56 100644 (file)
@@ -1,39 +1,40 @@
-import argparse
-from textwrap import dedent
+import docopt
 
 import teuthology.report
 
+doc = """
+usage:
+    teuthology-report -h
+    teuthology-report [-v] [-R] [-n] [-s SERVER] [-a ARCHIVE] -r RUN ...
+    teuthology-report [-v] [-R] [-n] [-s SERVER] [-a ARCHIVE] -r RUN -j JOB ...
+    teuthology-report [-v] [-R] [-n] [-s SERVER] [-a ARCHIVE] --all-runs
 
-def main():
-    teuthology.report.main(parse_args())
+Submit test results to a web service
+
+optional arguments:
+  -h, --help            show this help message and exit
+  -a ARCHIVE, --archive ARCHIVE
+                        The base archive directory
+                        [default: {archive_base}]
+  -r [RUN ...], --run [RUN ...]
+                        A run (or list of runs) to submit
+  -j [JOB ...], --job [JOB ...]
+                        A job (or list of jobs) to submit
+  --all-runs            Submit all runs in the archive
+  -R, --refresh         Re-push any runs already stored on the server. Note
+                        that this may be slow.
+  -s SERVER, --server SERVER
+                        "The server to post results to, e.g.
+                        http://localhost:8080/ . May also be specified in
+                        ~/.teuthology.yaml as 'results_server'
+  -n, --no-save         By default, when submitting all runs, we remember the
+                        last successful submission in a file called
+                        'last_successful_run'. Pass this flag to disable that
+                        behavior.
+  -v, --verbose         be more verbose
+""".format(archive_base=teuthology.config.config.archive_base)
 
 
-def parse_args():
-    parser = argparse.ArgumentParser(
-        description="Submit test results to a web service")
-    parser.add_argument('-a', '--archive', required=True,
-                        help="The base archive directory")
-    parser.add_argument('-r', '--run', nargs='*',
-                        help="A run (or list of runs) to submit")
-    parser.add_argument('--all-runs', action='store_true',
-                        help="Submit all runs in the archive")
-    parser.add_argument('-R', '--refresh', action='store_true', default=False,
-                        help=dedent("""Re-push any runs already stored on the
-                                    server. Note that this may be slow."""))
-    parser.add_argument('-s', '--server',
-                        help=dedent(""""The server to post results to, e.g.
-                                    http://localhost:8080/ . May also be
-                                    specified in ~/.teuthology.yaml as
-                                    'results_server'"""))
-    parser.add_argument('-n', '--no-save', dest='save',
-                        action='store_false', default=True,
-                        help=dedent("""By default, when submitting all runs, we
-                        remember the last successful submission in a file
-                        called 'last_successful_run'. Pass this flag to disable
-                        that behavior."""))
-    parser.add_argument(
-        '-v', '--verbose',
-        action='store_true', default=False,
-        help='be more verbose',
-    )
-    return parser.parse_args()
+def main():
+    args = docopt.docopt(doc)
+    teuthology.report.main(args)
index 21bcf5b2bd56651fdb4db3cc4e5e19213a9696da..d06380ac9b1590c7ec7f78e83c6c0e194c4da0c4 100644 (file)
@@ -15,17 +15,22 @@ log = logging.getLogger(__name__)
 
 
 def main(args):
-    if args.verbose:
+    if args['--verbose']:
         teuthology.log.setLevel(logging.DEBUG)
 
-    archive_base = os.path.abspath(os.path.expanduser(args.archive))
-    reporter = ResultsReporter(archive_base, base_uri=args.server,
-                               save=args.save, refresh=args.refresh)
-    if args.run and len(args.run) > 1:
-        reporter.report_runs(args.run)
-    elif args.run:
-        reporter.report_run(args.run[0])
-    elif args.all_runs:
+    archive_base = os.path.abspath(os.path.expanduser(args['--archive']))
+    save = not args['--no-save']
+    reporter = ResultsReporter(archive_base, base_uri=args['--server'],
+                               save=save, refresh=args['--refresh'])
+    run = args['--run']
+    job = args['--job']
+    if len(run) == 1 and job:
+        reporter.report_jobs(run[0], job)
+    elif run and len(run) > 1:
+        reporter.report_runs(run)
+    elif run:
+        reporter.report_run(run[0])
+    elif args['--all-runs']:
         reporter.report_all_runs()