forked from OK-DMR/Hytera_Homebrew_Bridge
-
Notifications
You must be signed in to change notification settings - Fork 1
/
start.py
executable file
·48 lines (40 loc) · 1.61 KB
/
start.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
44
45
46
47
48
#!/usr/bin/env python3
from threading import Thread
from hytera.p2p import P2PService
from hytera.dmr import DMRService
from hytera.rdac import RDACService
from hytera.storage import Storage
import configparser
class HyteraHomebrewBridge(Thread):
p2p_service: P2PService = P2PService()
dmr_service: DMRService = DMRService()
rdac_service: RDACService = RDACService()
storage: Storage = Storage()
def load_settings(self):
config = configparser.ConfigParser()
config.sections()
config.read("settings.ini")
if "constants" in config:
constants = config["constants"]
if "default_service_port" in constants:
self.storage.set_service_port(
P2PService.__name__, int(constants["default_service_port"])
)
if "default_dmr_port" in constants:
self.storage.set_service_port(
DMRService.__name__, int(constants["default_dmr_port"])
)
if "default_rdac_port" in constants:
self.storage.set_service_port(
RDACService.__name__, int(constants["default_rdac_port"])
)
if "default_service_ip" in constants:
self.storage.set_service_ip(str(constants["default_service_ip"]))
def start(self) -> None:
self.load_settings()
self.dmr_service.set_storage(self.storage).start()
self.rdac_service.set_storage(self.storage).start()
self.p2p_service.set_storage(self.storage).start()
if __name__ == "__main__":
t = HyteraHomebrewBridge()
t.start()