diff options
-rwxr-xr-x | main.py | 28 | ||||
-rw-r--r-- | static/style.css | 5 | ||||
-rw-r--r-- | templates/server_html.jinja | 3 |
3 files changed, 34 insertions, 2 deletions
@@ -4,6 +4,7 @@ from flask import Flask, flash, redirect, render_template, request, session, url # from wsgiref.util import setup_testing_defaults from collections import OrderedDict +from concurrent.futures import ThreadPoolExecutor import json import os @@ -172,8 +173,31 @@ def premades(): def server(): with open(os.path.join(CONFIG, 'server.json'), 'rt') as config: servers = json.load(config) - for name, server in servers.items(): - server['data'] = QueryServer.QueryServer(server['ip'], server['port'], server['gameid']) + + executor = ThreadPoolExecutor(max_workers=10) + serverdata_ = dict() + for _, serverdata in servers.items(): + name = "{0}{1:d}{2:d}".format(serverdata['ip'], serverdata['port'], serverdata['gameid']) + serverdata_[name] = executor.submit( + QueryServer.QueryServer, + serverdata['ip'], + serverdata['port'], + serverdata['gameid'] + ) + + for _, serverdata in servers.items(): + name = "{0}{1:d}{2:d}".format(serverdata['ip'], serverdata['port'], serverdata['gameid']) + serverdata['data'] = serverdata_[name].result() + serverdata_['u' + name] = executor.submit( + steam.getGameUpdateState, + serverdata['data']['gameid'], + serverdata['data']['gameversion'] + ) + + for _, serverdata in servers.items(): + name = "{0}{1:d}{2:d}".format(serverdata['ip'], serverdata['port'], serverdata['gameid']) + serverdata['update'] = serverdata_['u' + name].result() + return render_template('server_html.jinja', servers=servers, display_time = display_time diff --git a/static/style.css b/static/style.css index d27276f..9544769 100644 --- a/static/style.css +++ b/static/style.css @@ -183,6 +183,11 @@ div.serverdata { /* overflow: scroll; */ } +span.updatemessage { + color: red; + font-weight: bold; +} + a.servername { color: lightblue; font-weight: bold; diff --git a/templates/server_html.jinja b/templates/server_html.jinja index 5e38b0a..9702300 100644 --- a/templates/server_html.jinja +++ b/templates/server_html.jinja @@ -28,6 +28,9 @@ <li class="servermap">{{ info['data']['map'] }}</li> <li class="playerinfo">{{ info['data']['players'] }} / {{ info['data']['playersmax'] }}</li> </ul> + {% if info['update']['success'] %} + <span class="updatemessage">{{ info['update']['message'] }}</span> + {% endif %} {% if info['data']['players'] %} <table class="playerlist"> |