in support/retro_contest/rest.py [0:0]
def show_args(args, server, cookies):
endpoint = server + '/rest/job/status'
if args.all:
endpoint += '/all'
elif args.id:
endpoint += '/%d' % args.id
r = requests.get(endpoint, cookies=cookies)
if r.status_code == 404:
print('No job found')
return False
elif r.status_code == 200:
jobs = r.json()
if not args.all:
jobs = [jobs]
for job in jobs:
if args.verbose:
print('ID:', job['id'])
print('Status:', job['status'])
if 'score' in job:
print('Score:', job['score'])
print('Workers:')
for worker in job['workers']:
print('- Task:', worker['task'])
print(' Status:', worker['state'])
if 'eta' in worker:
print(' ETA (seconds):', worker['eta'])
if 'progress' in worker:
print(' Progress (percent):', worker['progress'] * 100)
if 'score' in worker:
print(' Score:', worker['score'])
if 'error' in worker:
print(' Error:', worker['error'])
else:
print('%i: %s' % (job['id'], job['status']))
else:
print('Error %i occurred' % r.status_code)
return False
return True