mirror of
https://github.com/blw1138/Zordon.git
synced 2025-12-20 02:08:12 +00:00
Feature/112 api version (#119)
* Add api_version to status api and server_proxy.py * Add api_version to Zeroconf and filter out incompatible versions when finding available servers * Filter incompatible versions from the UI
This commit is contained in:
@@ -25,11 +25,13 @@ from src.utilities.config import Config
|
||||
from src.utilities.misc_helper import system_safe_path, current_system_os, current_system_cpu, \
|
||||
current_system_os_version, num_to_alphanumeric
|
||||
from src.utilities.status_utils import string_to_status
|
||||
from version import APP_VERSION
|
||||
|
||||
logger = logging.getLogger()
|
||||
server = Flask(__name__)
|
||||
ssl._create_default_https_context = ssl._create_unverified_context # disable SSL for downloads
|
||||
|
||||
API_VERSION = "1"
|
||||
|
||||
def start_server(hostname=None):
|
||||
|
||||
@@ -236,7 +238,9 @@ def status():
|
||||
"memory_percent": psutil.virtual_memory().percent,
|
||||
"job_counts": RenderQueue.job_counts(),
|
||||
"hostname": server.config['HOSTNAME'],
|
||||
"port": server.config['PORT']
|
||||
"port": server.config['PORT'],
|
||||
"app_version": APP_VERSION,
|
||||
"api_version": API_VERSION
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -46,6 +46,7 @@ class RenderServerProxy:
|
||||
self.system_cpu_count = None
|
||||
self.system_os = None
|
||||
self.system_os_version = None
|
||||
self.system_api_version = None
|
||||
|
||||
# --------------------------------------------
|
||||
# Basics / Connection:
|
||||
@@ -100,8 +101,10 @@ class RenderServerProxy:
|
||||
return None
|
||||
|
||||
def request(self, payload, timeout=5):
|
||||
from src.api.api_server import API_VERSION
|
||||
hostname = LOOPBACK if self.is_localhost else self.hostname
|
||||
return requests.get(f'http://{hostname}:{self.port}/api/{payload}', timeout=timeout)
|
||||
return requests.get(f'http://{hostname}:{self.port}/api/{payload}', timeout=timeout,
|
||||
headers={"X-API-Version": str(API_VERSION)})
|
||||
|
||||
# --------------------------------------------
|
||||
# Background Updates:
|
||||
@@ -162,6 +165,7 @@ class RenderServerProxy:
|
||||
self.system_cpu_count = status['cpu_count']
|
||||
self.system_os = status['system_os']
|
||||
self.system_os_version = status['system_os_version']
|
||||
self.system_api_version = status['api_version']
|
||||
return status
|
||||
|
||||
# --------------------------------------------
|
||||
|
||||
Reference in New Issue
Block a user