blob: ef518094514ec09466f3dc5d980341267e9b8819 (
plain)
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
|
#!/usr/bin/env python3
from dial import DialManager, DialThread
from hangup import HangUpThread
from time import sleep
from queue import Queue
from threading import Event
if __name__ == "__main__":
queue = Queue()
phone_held = Event()
# start phone as on hook
phone_held.clear()
dial_thread = DialThread(queue, phone_held)
print("starting dial thread")
dial_thread.start()
dial_manager = DialManager()
hang_up_thread = HangUpThread(phone_held, dial_manager)
print("starting hang up thread")
hang_up_thread.start()
print("main loop")
while True:
phone_held.wait()
try:
dialed = queue.get(block=True, timeout=0.1)
except:
continue
response = dial_manager.dial(dialed)
if response is not None:
response.speak()
|