callmanager constructor
This commit is contained in:
@@ -10,16 +10,16 @@ OP_PING = 'PING'.encode()
|
|||||||
OP_OK = 'OK'.encode()
|
OP_OK = 'OK'.encode()
|
||||||
OP_ERROR = 'ERROR'.encode()
|
OP_ERROR = 'ERROR'.encode()
|
||||||
|
|
||||||
config = yaml.safe_load(open("intercom.yml"))
|
|
||||||
|
|
||||||
class CallManager:
|
class CallManager:
|
||||||
state = NO_CALL
|
def __init__(self, config):
|
||||||
station = None
|
self.config = config
|
||||||
call_process = None
|
self.state = NO_CALL
|
||||||
|
self.station = None
|
||||||
|
self.call_process = None
|
||||||
|
|
||||||
def call(self, station):
|
def call(self, station):
|
||||||
try:
|
try:
|
||||||
self.call_process = subprocess.Popen(['parole', '-c', station['host'], '-d', config['audio device']])
|
self.call_process = subprocess.Popen(['parole', '-c', station['host'], '-d', self.config['audio device']])
|
||||||
s = socket.socket()
|
s = socket.socket()
|
||||||
s.connect((station['host'], station['port']))
|
s.connect((station['host'], station['port']))
|
||||||
s.send(OP_CALL)
|
s.send(OP_CALL)
|
||||||
|
|||||||
10
intercom.py
10
intercom.py
@@ -10,7 +10,11 @@ from call_manager import CallManager, NO_CALL, INCOMING_CALL, OUTGOING_CALL, OP_
|
|||||||
|
|
||||||
CHECK_STATUS_INTERVAL = 120
|
CHECK_STATUS_INTERVAL = 120
|
||||||
|
|
||||||
callManager = CallManager()
|
|
||||||
|
config = yaml.safe_load(open("intercom.yml"))
|
||||||
|
port = config['port']
|
||||||
|
stations = config['stations']
|
||||||
|
callManager = CallManager(config)
|
||||||
|
|
||||||
|
|
||||||
def getstationbyip(ip):
|
def getstationbyip(ip):
|
||||||
@@ -70,10 +74,6 @@ def check_status(station):
|
|||||||
time.sleep(CHECK_STATUS_INTERVAL)
|
time.sleep(CHECK_STATUS_INTERVAL)
|
||||||
|
|
||||||
|
|
||||||
config = yaml.safe_load(open("intercom.yml"))
|
|
||||||
port = config['port']
|
|
||||||
stations = config['stations']
|
|
||||||
|
|
||||||
# Start thread to wait for incoming hang petitions.
|
# Start thread to wait for incoming hang petitions.
|
||||||
thread_listen = Thread(target=listen, args=(callManager,))
|
thread_listen = Thread(target=listen, args=(callManager,))
|
||||||
thread_listen.daemon = True
|
thread_listen.daemon = True
|
||||||
|
|||||||
Reference in New Issue
Block a user