mirror of
https://github.com/blw1138/Zordon.git
synced 2025-12-17 08:48:13 +00:00
Created start_client.py and moved server_proxy.py to server directory
This commit is contained in:
37
dashboard.py
37
dashboard.py
@@ -18,6 +18,7 @@ from rich.text import Text
|
||||
from rich.tree import Tree
|
||||
|
||||
from lib.render_workers.base_worker import RenderStatus, string_to_status
|
||||
from lib.server.server_proxy import RenderServerProxy
|
||||
from start_server import start_server
|
||||
|
||||
"""
|
||||
@@ -177,42 +178,6 @@ def create_status_panel(all_server_data):
|
||||
return "no status"
|
||||
|
||||
|
||||
class RenderServerProxy:
|
||||
|
||||
def __init__(self, server_ip=None, server_port="8080"):
|
||||
self.hostname = server_ip
|
||||
self.port = server_port
|
||||
self.local_hostname = local_hostname
|
||||
self.fetched_status_data = None
|
||||
|
||||
def connect(self):
|
||||
status = self.request_data('status')
|
||||
return status
|
||||
|
||||
def request_data(self, payload, timeout=5):
|
||||
try:
|
||||
req = requests.get(f'http://{self.hostname}:{self.port}/api/{payload}', timeout=timeout)
|
||||
if req.ok:
|
||||
return req.json()
|
||||
except Exception as e:
|
||||
pass
|
||||
return None
|
||||
|
||||
def get_jobs(self):
|
||||
all_jobs = self.request_data('jobs')
|
||||
sorted_jobs = []
|
||||
if all_jobs:
|
||||
for status_category in categories:
|
||||
found_jobs = [x for x in all_jobs if x['status'] == status_category.value]
|
||||
if found_jobs:
|
||||
sorted_jobs.extend(found_jobs)
|
||||
return sorted_jobs
|
||||
|
||||
def get_data(self, timeout=5):
|
||||
all_data = self.request_data('full_status', timeout=timeout)
|
||||
return all_data
|
||||
|
||||
|
||||
class KeyboardThread(threading.Thread):
|
||||
|
||||
def __init__(self, input_cbk = None, name='keyboard-input-thread'):
|
||||
|
||||
Reference in New Issue
Block a user