From dd4d97ffc9df52c925666260e19fe4941e7604f9 Mon Sep 17 00:00:00 2001 From: Nathan Woodburn Date: Fri, 25 Aug 2023 11:55:51 +1000 Subject: [PATCH] main: Fixed list workers --- master/main.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/master/main.py b/master/main.py index f7e475b..36cd397 100644 --- a/master/main.py +++ b/master/main.py @@ -174,10 +174,14 @@ def list_workers(): resp=requests.get("http://"+worker.split(':')[1].strip('\n') + ":5000/status",timeout=2) if (resp.status_code != 200): 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 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: return jsonify({'error': 'No workers available', 'success': 'false'})