From 1bf3a3dadbe9f7c79f36090cd5eb776741b6b193 Mon Sep 17 00:00:00 2001 From: Zack Cerza Date: Tue, 8 Oct 2013 14:21:23 -0500 Subject: [PATCH] Move teuthology-worker's arg parsing to scripts/ Signed-off-by: Zack Cerza --- scripts/worker.py | 37 +++++++++++++++++++++++++++++++++++++ setup.py | 2 +- teuthology/queue.py | 30 +----------------------------- 3 files changed, 39 insertions(+), 30 deletions(-) create mode 100644 scripts/worker.py diff --git a/scripts/worker.py b/scripts/worker.py new file mode 100644 index 0000000000000..4e8feac616bbb --- /dev/null +++ b/scripts/worker.py @@ -0,0 +1,37 @@ +import argparse + +import teuthology.queue + + +def main(): + teuthology.queue.worker(parse_args()) + + +def parse_args(): + parser = argparse.ArgumentParser(description=""" +Grab jobs from a beanstalk queue and run the teuthology tests they +describe. One job is run at a time. +""") + parser.add_argument( + '-v', '--verbose', + action='store_true', default=None, + help='be more verbose', + ) + parser.add_argument( + '--archive-dir', + metavar='DIR', + help='path under which to archive results', + required=True, + ) + parser.add_argument( + '-l', '--log-dir', + help='path in which to store logs', + required=True, + ) + parser.add_argument( + '-t', '--tube', + help='which beanstalk tube to read jobs from', + required=True, + ) + + return parser.parse_args() diff --git a/setup.py b/setup.py index 3b0c4bfeb99aa..21f9bff9feb18 100644 --- a/setup.py +++ b/setup.py @@ -20,7 +20,7 @@ setup( 'teuthology-nuke = scripts.nuke:main', 'teuthology-suite = scripts.suite:main', 'teuthology-ls = scripts.ls:main', - 'teuthology-worker = teuthology.queue:worker', + 'teuthology-worker = scripts.worker:main', 'teuthology-lock = teuthology.lock:main', 'teuthology-schedule = teuthology.run:schedule', 'teuthology-updatekeys = teuthology.lock:update_hostkeys', diff --git a/teuthology/queue.py b/teuthology/queue.py index 4c5451c1091b8..2fae7d8b99d10 100644 --- a/teuthology/queue.py +++ b/teuthology/queue.py @@ -93,35 +93,7 @@ def fetch_teuthology_branch(path, branch='master'): finally: lock.release() -def worker(): - parser = argparse.ArgumentParser(description=""" -Grab jobs from a beanstalk queue and run the teuthology tests they -describe. One job is run at a time. -""") - parser.add_argument( - '-v', '--verbose', - action='store_true', default=None, - help='be more verbose', - ) - parser.add_argument( - '--archive-dir', - metavar='DIR', - help='path under which to archive results', - required=True, - ) - parser.add_argument( - '-l', '--log-dir', - help='path in which to store logs', - required=True, - ) - parser.add_argument( - '-t', '--tube', - help='which beanstalk tube to read jobs from', - required=True, - ) - - ctx = parser.parse_args() - +def worker(ctx): loglevel = logging.INFO if ctx.verbose: loglevel = logging.DEBUG -- 2.39.5