Skip to content

Commit

Permalink
Move teuthology-ls's arg parsing to scripts/
Browse files Browse the repository at this point in the history
Signed-off-by: Zack Cerza <[email protected]>
  • Loading branch information
zmc committed Oct 11, 2013
1 parent 7805913 commit 5fd1cd0
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 21 deletions.
23 changes: 23 additions & 0 deletions scripts/ls.py
Original file line number Diff line number Diff line change
@@ -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()
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
'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',
Expand Down
28 changes: 8 additions & 20 deletions teuthology/suite.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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:
Expand All @@ -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):
Expand Down

0 comments on commit 5fd1cd0

Please sign in to comment.