example processing
This commit is contained in:
parent
aeae602344
commit
d863712630
7
README.md
Normal file
7
README.md
Normal file
|
@ -0,0 +1,7 @@
|
|||
# Flughafen Sensor foo
|
||||
|
||||
Das Projekt wird gestartet mit `docker compose up` (`docker-compose up`)
|
||||
|
||||
Bisher werden nur daten des Typs "online-level" verarbeitet, aber der Rest sollte einigermassen trivial sein.
|
||||
|
||||
Ich habe keine Ahnung, wie und in welchem Format ihr das an euren zentralen Thinger Server senden wollt, aber kÃnnt ihr vieleicht auch selber erledigen.
|
23
server.py
23
server.py
|
@ -19,20 +19,29 @@ driver = webdriver.Chrome(options=options)
|
|||
|
||||
|
||||
def interceptor(request, response): # A response interceptor takes two args
|
||||
if 'ws-travis.dus.com/socket.io/' in request.url :
|
||||
if 'ws-travis.dus.com/socket.io/?EIO=3&transport=polling' in request.url :
|
||||
body = decode(response.body, response.headers.get('Content-Encoding', 'identity'))
|
||||
x = re.split("\d\d\d:\d\d\/dus,", body.decode("utf-8"))
|
||||
if len(x) > 1:
|
||||
for i in [i for i in x if i]:
|
||||
j = json.loads(i)
|
||||
print (j)
|
||||
handleJson(j)
|
||||
else:
|
||||
j = json.loads(x)
|
||||
print (j)
|
||||
#offset = str(body).find('[')
|
||||
#print ("\n" , str(body)[offset:] , "\n")
|
||||
#j = json.loads(body[offset:])
|
||||
#print (x)
|
||||
handleJson(j)
|
||||
|
||||
def handleJson(jsonObj):
|
||||
|
||||
if jsonObj[0] == 'online-level':
|
||||
typ = jsonObj[1]["LevelValues"][0]["Type"]
|
||||
values = jsonObj[1]["LevelValues"][0]["Values"]
|
||||
NmtId = jsonObj[1]["NmtId"]
|
||||
time = jsonObj[1]["Time"]
|
||||
|
||||
print ("\n", jsonObj)
|
||||
print ("[", time, "]: ", "NmtId: ", NmtId, " Typ: ", typ, " Wert: ", values)
|
||||
print ("\n")
|
||||
|
||||
|
||||
driver.response_interceptor = interceptor
|
||||
|
||||
|
|
Loading…
Reference in a new issue