]> git.apps.os.sepia.ceph.com Git - teuthology.git/commitdiff
Move teuthology-ls's arg parsing to scripts/
authorZack Cerza <zack@cerza.org>
Tue, 8 Oct 2013 16:54:41 +0000 (11:54 -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/ls.py [new file with mode: 0644]
setup.py
teuthology/suite.py

diff --git a/scripts/ls.py b/scripts/ls.py
new file mode 100644 (file)
index 0000000..f3109b4
--- /dev/null
@@ -0,0 +1,23 @@
+import argparse
+from teuthology.suite import ls
+
+
+def main():
+    args = parse_args()
+    ls(args.archive_dir, args.verbose)
+
+
+def parse_args():
+    parser = argparse.ArgumentParser(description='List teuthology job results')
+    parser.add_argument(
+        '--archive-dir',
+        metavar='DIR',
+        help='path under which to archive results',
+        required=True,
+    )
+    parser.add_argument(
+        '-v', '--verbose',
+        action='store_true', default=False,
+        help='show reasons tests failed',
+    )
+    return parser.parse_args()
index d3df1c6acbe244d1e58e5810a0c457681a06fd73..3b0c4bfeb99aa3c6627ae9c3f4d6c6e8b0f5b15c 100644 (file)
--- a/setup.py
+++ b/setup.py
@@ -19,7 +19,7 @@ setup(
             'teuthology = teuthology.run:main',
             'teuthology-nuke = scripts.nuke:main',
             'teuthology-suite = scripts.suite:main',
-            'teuthology-ls = teuthology.suite:ls',
+            'teuthology-ls = scripts.ls:main',
             'teuthology-worker = teuthology.queue:worker',
             'teuthology-lock = teuthology.lock:main',
             'teuthology-schedule = teuthology.run:schedule',
index 42cc2e37fbdfa9ad7371e118f25404a81d50e551..49a978ef12b3d76f5b170b5132a569a349fc1bf7 100644 (file)
@@ -190,23 +190,10 @@ def build_matrix(path):
             return out
     return []
 
-def ls():
-    parser = argparse.ArgumentParser(description='List teuthology job results')
-    parser.add_argument(
-        '--archive-dir',
-        metavar='DIR',
-        help='path under which to archive results',
-        required=True,
-        )
-    parser.add_argument(
-        '-v', '--verbose',
-        action='store_true', default=False,
-        help='show reasons tests failed',
-        )
-    args = parser.parse_args()
 
-    for j in get_jobs(args.archive_dir):
-        job_dir = os.path.join(args.archive_dir, j)
+def ls(archive_dir, verbose):
+    for j in get_jobs(archive_dir):
+        job_dir = os.path.join(archive_dir, j)
         summary = {}
         try:
             with file(os.path.join(job_dir, 'summary.yaml')) as f:
@@ -224,15 +211,16 @@ def ls():
                     if os.path.isfile(pidfile):
                         pid = open(pidfile, 'r').read()
                         if os.path.isdir("/proc/%s" % pid):
-                            cmdline = open('/proc/%s/cmdline' % pid, 'r').read()
-                            if cmdline.find(args.archive_dir) >= 0:
+                            cmdline = open('/proc/%s/cmdline' % pid,
+                                           'r').read()
+                            if cmdline.find(archive_dir) >= 0:
                                 print '(pid %s)' % pid,
                                 found = True
                     if not found:
                         print '(no process or summary.yaml)',
                     # tail
                     tail = os.popen(
-                        'tail -1 %s/%s/teuthology.log' % (args.archive_dir, j)
+                        'tail -1 %s/%s/teuthology.log' % (archive_dir, j)
                         ).read().rstrip()
                     print tail,
                 except IOError, e:
@@ -249,7 +237,7 @@ def ls():
             success='pass' if summary.get('success', False) else 'FAIL',
             duration=int(summary.get('duration', 0)),
             )
-        if args.verbose and 'failure_reason' in summary:
+        if verbose and 'failure_reason' in summary:
             print '    {reason}'.format(reason=summary['failure_reason'])
 
 def generate_coverage(args):