example processing

This commit is contained in:
Bla 2023-10-12 15:25:46 +00:00
parent aeae602344
commit d863712630
2 changed files with 23 additions and 7 deletions

7
README.md Normal file
View 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.

View file

@ -19,20 +19,29 @@ driver = webdriver.Chrome(options=options)
def interceptor(request, response): # A response interceptor takes two args 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')) body = decode(response.body, response.headers.get('Content-Encoding', 'identity'))
x = re.split("\d\d\d:\d\d\/dus,", body.decode("utf-8")) x = re.split("\d\d\d:\d\d\/dus,", body.decode("utf-8"))
if len(x) > 1: if len(x) > 1:
for i in [i for i in x if i]: for i in [i for i in x if i]:
j = json.loads(i) j = json.loads(i)
print (j) handleJson(j)
else: else:
j = json.loads(x) j = json.loads(x)
print (j) handleJson(j)
#offset = str(body).find('[')
#print ("\n" , str(body)[offset:] , "\n") def handleJson(jsonObj):
#j = json.loads(body[offset:])
#print (x) 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 driver.response_interceptor = interceptor