re-implement the status page
This commit is contained in:
parent
dac35ae526
commit
1c4543b7bf
@ -34,7 +34,22 @@ class Controller(object):
|
|||||||
|
|
||||||
class StatusController(Controller):
|
class StatusController(Controller):
|
||||||
def handle_request(self):
|
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):
|
class AssetsController(Controller):
|
||||||
def serve_file(self, file, content_type = None):
|
def serve_file(self, file, content_type = None):
|
||||||
|
@ -521,7 +521,7 @@ class ClientReporterThread(threading.Thread):
|
|||||||
|
|
||||||
def run(self):
|
def run(self):
|
||||||
while (self.doRun):
|
while (self.doRun):
|
||||||
n = len(self.clients)
|
n = self.clientCount()
|
||||||
for c in self.clients:
|
for c in self.clients:
|
||||||
c.write_clients(n)
|
c.write_clients(n)
|
||||||
time.sleep(3)
|
time.sleep(3)
|
||||||
@ -533,6 +533,9 @@ class ClientReporterThread(threading.Thread):
|
|||||||
raise TooManyClientsException()
|
raise TooManyClientsException()
|
||||||
self.clients.append(client)
|
self.clients.append(client)
|
||||||
|
|
||||||
|
def clientCount(self):
|
||||||
|
return len(self.clients)
|
||||||
|
|
||||||
def removeClient(self, client):
|
def removeClient(self, client):
|
||||||
try:
|
try:
|
||||||
self.clients.remove(client)
|
self.clients.remove(client)
|
||||||
|
Loading…
Reference in New Issue
Block a user