From 03974bf583677d181d31ebaa357b22cfb3700b6d Mon Sep 17 00:00:00 2001 From: Zack Cerza Date: Tue, 25 Mar 2014 15:38:34 -0500 Subject: [PATCH] Add --description flag Default to not printing job descriptions. Add -d/--description flag to control that behavior. Change --delete's short option to -D. Other small output tweaks. Signed-off-by: Zack Cerza --- scripts/queue.py | 9 +++++---- teuthology/beanstalk.py | 9 +++++---- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/scripts/queue.py b/scripts/queue.py index 2aa239cc3a..2dc1bd4b2b 100644 --- a/scripts/queue.py +++ b/scripts/queue.py @@ -5,8 +5,8 @@ import teuthology.beanstalk doc = """ usage: teuthology-queue -h - teuthology-queue -m MACHINE_TYPE - teuthology-queue -m MACHINE_TYPE -d PATTERN + teuthology-queue [-d] -m MACHINE_TYPE + teuthology-queue -m MACHINE_TYPE -D PATTERN List Jobs in queue: If -d then jobs with PATTERN in the job name are deleted from the queue. @@ -16,9 +16,10 @@ Arguments: Which machine type queue to work on. optional arguments: - -h, --help show this help message and exit + -h, --help Show this help message and exit + -D, --delete PATTERN Delete Jobs with PATTERN in their name + -d, --description Show job descriptions - -d, --delete PATTERN Delete Jobs with PATTERN in their name. """.format(archive_base=teuthology.config.config.archive_base) diff --git a/teuthology/beanstalk.py b/teuthology/beanstalk.py index 344ea798b1..bcc4ceb28b 100644 --- a/teuthology/beanstalk.py +++ b/teuthology/beanstalk.py @@ -21,7 +21,7 @@ def beanstalk_connect(machine_type): return beanstalk -def walk_jobs(beanstalk, machine_type, delete=None): +def walk_jobs(beanstalk, machine_type, show_desc=False, delete=None): job_count = beanstalk.stats_tube(machine_type)['current-jobs-ready'] if job_count == 0: log.info('No jobs in Beanstalk Queue') @@ -48,14 +48,14 @@ def walk_jobs(beanstalk, machine_type, delete=None): x=x, count=job_count) print m, else: - m = 'Job: {x}/{count} ID: {job_id} Name: {job_name}'.format( + m = 'Job: {x}/{count} {job_name}/{job_id}'.format( x=x, count=job_count, job_id=job_id, job_name=job_name, ) print m - if job_description: + if job_description and show_desc: for desc in job_description.split(): print '\t {desc}'.format(desc=desc) log.info("Finished checking Beanstalk Queue.") @@ -64,6 +64,7 @@ def walk_jobs(beanstalk, machine_type, delete=None): def main(args): machine_type = args['--machine_type'] delete = args['--delete'] + show_desc = args['--description'] beanstalk = beanstalk_connect(machine_type) - walk_jobs(beanstalk, machine_type, delete) + walk_jobs(beanstalk, machine_type, show_desc=show_desc, delete=delete) beanstalk.close() -- 2.39.5