-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)
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()