mirror of
https://github.com/Telecominfraproject/wlan-lanforge-scripts.git
synced 2025-11-01 19:28:00 +00:00
Added websocket generic listener for port 8081, added a test script for it and updated test_ipv4_connection.py to add websocket events
This commit is contained in:
28
py-scripts/ws_generic_monitor_test.py
Normal file
28
py-scripts/ws_generic_monitor_test.py
Normal file
@@ -0,0 +1,28 @@
|
||||
"""
|
||||
This example is to demonstrate ws_generic_monitor to monitor events triggered by scripts,
|
||||
This script when running, will monitor the events triggered by test_ipv4_connection.py
|
||||
|
||||
"""
|
||||
|
||||
|
||||
import sys
|
||||
import json
|
||||
if 'py-json' not in sys.path:
|
||||
sys.path.append('../py-json')
|
||||
from ws_generic_monitor import WS_Listener
|
||||
|
||||
reference = "test_ipv4_connection.py"
|
||||
def main():
|
||||
WS_Listener(lfclient_host="192.168.200.15", _scriptname=reference, _callback=TestRun)
|
||||
|
||||
|
||||
def TestRun(ws, message):
|
||||
if (str(message).__contains__(reference)):
|
||||
#print(message)
|
||||
temp = json.loads(message)
|
||||
event_message = str(temp['name']) + "/" + str(temp['details']) + "/" + str(temp['timestamp'])
|
||||
print(event_message)
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
|
||||
Reference in New Issue
Block a user