Debian Codegraph @

examples/originate.py

raw symbols SCIP
1 """
2 Example script to originate a call through Asterisk Manager Interface.
3
4 Usage: python originate.py config.ini
5
6 """
7 import sys
8 import asyncio
9 from panoramisk.call_manager import CallManager
10
11
12 async def originate():
13 callmanager = CallManager.from_config(sys.argv[1])
14 await callmanager.connect()
15 call = await callmanager.send_originate({
16 'Action': 'Originate',
17 'Channel': 'Local/gpasgrimaud@bearstech',
18 'WaitTime': 20,
19 'CallerID': 'gawel',
20 'Exten': '1000',
21 'Context': 'ael-demo',
22 'Priority': 1})
23 print(call)
24 while not call.queue.empty():
25 event = call.queue.get_nowait()
26 print(event)
27 while True:
28 event = await call.queue.get()
29 print(event)
30 if event.event.lower() == 'hangup' and event.cause in ('0', '17'):
31 break
32 callmanager.clean_originate(call)
33 callmanager.close()
34
35
36 def main():
37 loop = asyncio.get_event_loop()
38 loop.run_until_complete(originate())
39 loop.close()
40
41
42 if __name__ == '__main__':
43 main()