Now loads config from YAMl
This commit is contained in:
parent
4760930c4f
commit
e8d230b31a
|
@ -2,6 +2,7 @@ import websocket
|
|||
import _thread
|
||||
import time
|
||||
import ssl
|
||||
import yaml
|
||||
|
||||
def on_message(ws, message):
|
||||
print(f"<< {message}")
|
||||
|
@ -24,11 +25,18 @@ def on_open(ws):
|
|||
ws.close()
|
||||
_thread.start_new_thread(run, ())
|
||||
|
||||
if __name__ == "__main__":
|
||||
def open_socket(url, port):
|
||||
websocket.enableTrace(True)
|
||||
ws = websocket.WebSocketApp("ws://localhost:6873",
|
||||
ws = websocket.WebSocketApp(f"ws://{url}:{port}",
|
||||
on_open=on_open,
|
||||
on_message=on_message,
|
||||
on_error=on_error,
|
||||
on_close=on_close)
|
||||
ws.run_forever(sslopt={"cert_reqs": ssl.CERT_NONE})
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
with open('config.yaml', 'r') as f:
|
||||
conf = yaml.safe_load(f)
|
||||
open_socket(conf['ws']['url'], conf['ws']['port'])
|
||||
|
||||
|
|
3
src/client/test_config.yaml
Normal file
3
src/client/test_config.yaml
Normal file
|
@ -0,0 +1,3 @@
|
|||
ws:
|
||||
url: localhost
|
||||
port: 6873
|
Loading…
Reference in New Issue
Block a user