From 52da4e3a5a72ccdc6ad227c8bad7484aa65c9dcd Mon Sep 17 00:00:00 2001 From: Vidal Quevedo Date: Sat, 1 Mar 2014 15:28:33 -0600 Subject: [PATCH] Add --status option to filter job list by job status The --status option allows the users to only list jobs with a specific status (options: open, quoted, accepted, rejected, running, or delivered). --- src/list_jobs.py | 41 ++++++++++++++++++++++++----------------- 1 file changed, 24 insertions(+), 17 deletions(-) diff --git a/src/list_jobs.py b/src/list_jobs.py index 6b3e1fd..3b5369e 100755 --- a/src/list_jobs.py +++ b/src/list_jobs.py @@ -7,28 +7,35 @@ class ListJobs(GnipHistoricalCmd): def setOptions(self, parser): parser.add_option("-d", "--since-date", dest="sinceDateString", default=None, help="Only list jobs after date, (default 2012-01-01T00:00:00)") + parser.add_option("-s", "--status", dest="statusString", default=None, + help="Only list jobs with a specific status (options: open, quoted, accepted, rejected, running, or delivered") + + # available statuses: rejected, accepted, running, quoted def output(self, status): - if self.options.verbose: - status = self.gnipHistorical.getJobStatus(status.jobURL) - print str(status) - if status.result is not None: - status.result.write() + if self.options.statusString is not None and status.status != self.options.statusString: + return else: - print "#"*25 - print "TITLE: ",status.title - print "STATUS: ",status.status - print "PROGRESS: ",status.percentComplete,"%" - print "JOB URL: ",status.jobURL - if self.options.prevUrl or self.options.url is not None: + if self.options.verbose: + status = self.gnipHistorical.getJobStatus(status.jobURL) + print str(status) if status.result is not None: - print - print str(status.quote) - print str(status.result) - print "Writing files to data_files.txt..." status.result.write() - elif status.status.lower().startswith("delivered"): - print 'Data files available, use "-v, -u or -l" flag to download files list.' + else: + print "#"*25 + print "TITLE: ",status.title + print "STATUS: ",status.status + print "PROGRESS: ",status.percentComplete,"%" + print "JOB URL: ",status.jobURL + if self.options.prevUrl or self.options.url is not None: + if status.result is not None: + print + print str(status.quote) + print str(status.result) + print "Writing files to data_files.txt..." + status.result.write() + elif status.status.lower().startswith("delivered"): + print 'Data files available, use "-v, -u or -l" flag to download files list.' def __call__(self): if self.userUrl is None: