Statuspage changes
This commit is contained in:
parent
7fae18b6d8
commit
bd326d0211
1 changed files with 10 additions and 3 deletions
|
@ -15,6 +15,7 @@ from sorteerhoed.Signal import Signal
|
||||||
import httpagentparser
|
import httpagentparser
|
||||||
import geoip2.database
|
import geoip2.database
|
||||||
import queue
|
import queue
|
||||||
|
import datetime
|
||||||
|
|
||||||
|
|
||||||
logger = logging.getLogger("sorteerhoed").getChild("webserver")
|
logger = logging.getLogger("sorteerhoed").getChild("webserver")
|
||||||
|
@ -172,7 +173,8 @@ class StatusWebSocketHandler(tornado.websocket.WebSocketHandler):
|
||||||
connections = set()
|
connections = set()
|
||||||
queue = queue.Queue()
|
queue = queue.Queue()
|
||||||
|
|
||||||
def initialize(self):
|
def initialize(self, statusPage):
|
||||||
|
self.statusPage = statusPage
|
||||||
pass
|
pass
|
||||||
|
|
||||||
def check_origin(self, origin):
|
def check_origin(self, origin):
|
||||||
|
@ -184,6 +186,11 @@ class StatusWebSocketHandler(tornado.websocket.WebSocketHandler):
|
||||||
# the client connected
|
# the client connected
|
||||||
def open(self, p = None):
|
def open(self, p = None):
|
||||||
self.__class__.connections.add(self)
|
self.__class__.connections.add(self)
|
||||||
|
for prop, value in enumerate(self.statusPage.__dict__):
|
||||||
|
self.write_message(json.dumps({
|
||||||
|
'property': prop,
|
||||||
|
'value': value.isoformat(timespec='seconds') if type(value) is datetime.datetime else value
|
||||||
|
}))
|
||||||
|
|
||||||
|
|
||||||
# client disconnected
|
# client disconnected
|
||||||
|
@ -203,7 +210,7 @@ class StatusWebSocketHandler(tornado.websocket.WebSocketHandler):
|
||||||
for connection in cls.connections:
|
for connection in cls.connections:
|
||||||
connection.write_message(json.dumps({
|
connection.write_message(json.dumps({
|
||||||
'property': prop,
|
'property': prop,
|
||||||
'value': value
|
'value': value.isoformat(timespec='seconds') if type(value) is datetime.datetime else value
|
||||||
}))
|
}))
|
||||||
|
|
||||||
def strokes2D(strokes):
|
def strokes2D(strokes):
|
||||||
|
@ -406,7 +413,7 @@ class Server:
|
||||||
'eventQ': self.eventQ,
|
'eventQ': self.eventQ,
|
||||||
'store': self.store,
|
'store': self.store,
|
||||||
}),
|
}),
|
||||||
(r"/status/ws", StatusWebSocketHandler),
|
(r"/status/ws", StatusWebSocketHandler, dict(statusPage = self.statusPage)),
|
||||||
(r"/draw", DrawPageHandler,
|
(r"/draw", DrawPageHandler,
|
||||||
dict(
|
dict(
|
||||||
store = self.store,
|
store = self.store,
|
||||||
|
|
Loading…
Reference in a new issue