Skip to content

Commit 3b08a0a

Browse files
committed
some more error handling
1 parent de7ce6e commit 3b08a0a

1 file changed

Lines changed: 11 additions & 2 deletions

File tree

bin/drqueue

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -273,6 +273,10 @@ def job_list(args):
273273
jobs = client.query_job_list()
274274
print "Listing all jobs"
275275

276+
if len(jobs) == 0:
277+
print('No jobs found')
278+
sys.exit(-1)
279+
276280
# run action on every job
277281
for job in jobs:
278282
# walk through tasks of every job
@@ -459,8 +463,13 @@ def job_delete(args):
459463

460464
# run action on every job
461465
for job in jobs:
462-
client.job_delete(job['_id'])
463-
print("Job %s has been deleted.\n" % job['name'])
466+
if job == None:
467+
print('ERROR: No such job')
468+
sys.exit(-1)
469+
if client.job_delete(job['_id']) == True:
470+
print("Job %s has been deleted.\n" % job['name'])
471+
else:
472+
print("Job %s could not be deleted.\n" % job['name'])
464473

465474

466475
def job_continue(args):

0 commit comments

Comments
 (0)