diff options
Diffstat (limited to 'lava_scheduler_tool/commands.py')
-rw-r--r-- | lava_scheduler_tool/commands.py | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/lava_scheduler_tool/commands.py b/lava_scheduler_tool/commands.py index 3529617..367dfda 100644 --- a/lava_scheduler_tool/commands.py +++ b/lava_scheduler_tool/commands.py @@ -19,6 +19,7 @@ import os import sys import argparse +import time import xmlrpclib from lava_tool.authtoken import AuthenticatingServerProxy, KeyringAuthBackend @@ -44,6 +45,9 @@ class submit_job(Command): super(submit_job, cls).register_arguments(parser) parser.add_argument("SERVER") parser.add_argument("JSON_FILE") + parser.add_argument("--block", + action="store_true", + help="Blocks until the job gets executed") def invoke(self): server = AuthenticatingServerProxy( @@ -57,6 +61,23 @@ class submit_job(Command): else: print "submitted as job id:", job_id + if self.args.block: + print('') + print('Waiting for the job to run ') + print('. = job waiting in the queue') + print('# = job running') + print('') + job = {'job_status': 'Unknown'} + progress = {'Submitted': '.', 'Running': '#'} + while job['job_status'] in ['Unknown', 'Submitted', 'Running']: + job = server.scheduler.job_status(job_id) + sys.stdout.write(progress.get(job['job_status'], '')) + sys.stdout.flush() + time.sleep(10) # seconds + print('') + print('') + print('Job Status: %s' % job['job_status']) + class resubmit_job(Command): |