re-implement the status page

This commit is contained in:
Jakob Ketterl 2019-05-10 23:00:18 +02:00
parent dac35ae526
commit 1c4543b7bf
2 changed files with 20 additions and 2 deletions

View File

@ -34,7 +34,22 @@ class Controller(object):
class StatusController(Controller):
def handle_request(self):
self.send_response("you have reached the status page!")
pm = PropertyManager.getSharedInstance()
# TODO keys that have been left out since they are no longer simple strings: sdr_hw, bands, antenna
vars = {
"status": "active",
"name": pm["receiver_name"],
"op_email": pm["receiver_admin"],
"users": ClientReporterThread.getSharedInstance().clientCount(),
"users_max": pm["max_clients"],
"gps": pm["receiver_gps"],
"asl": pm["receiver_asl"],
"loc": pm["receiver_location"],
# TODO get some version in there
"sw_version": "TODO",
"avatar_ctime": os.path.getctime("htdocs/gfx/openwebrx-avatar.png")
}
self.send_response("\n".join(["{key}={value}".format(key = key, value = value) for key, value in vars.items()]))
class AssetsController(Controller):
def serve_file(self, file, content_type = None):

View File

@ -521,7 +521,7 @@ class ClientReporterThread(threading.Thread):
def run(self):
while (self.doRun):
n = len(self.clients)
n = self.clientCount()
for c in self.clients:
c.write_clients(n)
time.sleep(3)
@ -533,6 +533,9 @@ class ClientReporterThread(threading.Thread):
raise TooManyClientsException()
self.clients.append(client)
def clientCount(self):
return len(self.clients)
def removeClient(self, client):
try:
self.clients.remove(client)