]> git.apps.os.sepia.ceph.com Git - teuthology.git/commitdiff
Move teuthology-report's arg parsing to scripts/
authorZack Cerza <zack@cerza.org>
Tue, 8 Oct 2013 22:07:01 +0000 (17:07 -0500)
committerZack Cerza <zack@cerza.org>
Fri, 11 Oct 2013 00:09:34 +0000 (19:09 -0500)
Signed-off-by: Zack Cerza <zack.cerza@inktank.com>
scripts/report.py [new file with mode: 0644]
setup.py
teuthology/report.py [changed mode: 0755->0644]

diff --git a/scripts/report.py b/scripts/report.py
new file mode 100644 (file)
index 0000000..7d51dcd
--- /dev/null
@@ -0,0 +1,34 @@
+import argparse
+from textwrap import dedent
+
+import teuthology.report
+
+
+def main():
+    teuthology.report.main(parse_args())
+
+
+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."""))
+    return parser.parse_args()
index d926cf2131aa42e9821187b4d036565cac821c1a..b85b859daf84d998bcd6cc2659d59ab30f510c4b 100644 (file)
--- a/setup.py
+++ b/setup.py
@@ -26,7 +26,7 @@ setup(
             'teuthology-updatekeys = scripts.updatekeys:main',
             'teuthology-coverage = teuthology.coverage:analyze',
             'teuthology-results = teuthology.suite:results',
-            'teuthology-report = teuthology.report:main',
+            'teuthology-report = scripts.report:main',
             ],
         },
 
old mode 100755 (executable)
new mode 100644 (file)
index afecfd1..c37e265
@@ -1,5 +1,3 @@
-#!/usr/bin/env python
-
 import os
 import yaml
 import json
@@ -7,8 +5,6 @@ import re
 import httplib2
 import urllib
 import logging
-import argparse
-from textwrap import dedent
 
 from teuthology.config import config
 
@@ -17,6 +13,18 @@ log = logging.getLogger(__name__)
 logging.basicConfig(level=logging.INFO)
 
 
+def main(args):
+    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:
+        reporter.report_all_runs()
+
+
 class RequestFailedError(RuntimeError):
     def __init__(self, uri, resp, content):
         self.uri = uri
@@ -364,47 +372,3 @@ def try_push_job_info(job_config, extra_info=None):
         except RequestFailedError:
             log.exception("Could not report results to %s" %
                           config.results_server)
-
-
-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."""))
-    args = parser.parse_args()
-    return args
-
-
-def main():
-    args = parse_args()
-    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:
-        reporter.report_all_runs()
-
-
-if __name__ == "__main__":
-    main()