main: Fixed list workers

This commit is contained in:
Nathan Woodburn 2023-08-25 11:55:51 +10:00
parent 6d28cf7431
commit dd4d97ffc9
Signed by: nathanwoodburn
GPG Key ID: 203B000478AD0EF1

View File

@ -174,10 +174,14 @@ def list_workers():
resp=requests.get("http://"+worker.split(':')[1].strip('\n') + ":5000/status",timeout=2) resp=requests.get("http://"+worker.split(':')[1].strip('\n') + ":5000/status",timeout=2)
if (resp.status_code != 200): if (resp.status_code != 200):
online=False online=False
worker_list.append({'worker': worker.split(':')[0],'ip': worker.split(':')[1].strip('\n'), 'online': online, 'sites': 0, 'ready': 0}) worker_list.append({'worker': worker.split(':')[0],'ip': worker.split(':')[1].strip('\n'), 'online': online, 'sites': 0, 'status': 'offline'})
continue continue
sites = resp.json()['num_sites'] sites = resp.json()['num_sites']
worker_list.append({'worker': worker.split(':')[0],'ip': worker.split(':')[1].strip('\n'), 'online': online, 'sites': sites, 'ready': 1}) availability = resp.json()['availability']
if availability == True:
worker_list.append({'worker': worker.split(':')[0],'ip': worker.split(':')[1].strip('\n'), 'online': online, 'sites': sites, 'status': 'ready'})
else:
worker_list.append({'worker': worker.split(':')[0],'ip': worker.split(':')[1].strip('\n'), 'online': online, 'sites': sites, 'status': 'full'})
if len(worker_list) == 0: if len(worker_list) == 0:
return jsonify({'error': 'No workers available', 'success': 'false'}) return jsonify({'error': 'No workers available', 'success': 'false'})