-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathmain.py
43 lines (32 loc) · 1.1 KB
/
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
import logging
import os
from dotenv import load_dotenv
load_dotenv(override=True)
def main():
from src import Client, Config, InterceptHandler, Logging, WebSocketConnectionConfig, WebSocketService
config = Config()
logger = Logging(
retention=config["log"]["retention"],
debug_mode=config["debug-mode"],
format=config["log"]["format"],
).get_logger()
logging.basicConfig(
handlers=[InterceptHandler(logger)],
level=0 if config["debug-mode"] else logging.INFO,
force=True,
)
key = os.getenv("API_KEY")
if key:
logger.info("API_KEY found, using WebSocket Client")
ws_config = WebSocketConnectionConfig(
key=key, service=[WebSocketService.EEW, WebSocketService.TREM_EEW]
)
else:
logger.info("API_KEY not found, using HTTP Client")
ws_config = None
client = Client(config=config, logger=logger, websocket_config=ws_config, debug=config["debug-mode"])
client.load_notification_clients("notification")
client.run()
logger.remove()
if __name__ == "__main__":
main()