From: Matthew N. <mni...@di...> - 2006-10-25 17:45:55
|
DomDom wrote: > Hello, > > I am new to Asterisk and relatively new to Python (I write some small > programs). > I am sorry that my questions may seem stupid to some but answers will > help me a lot. > > I would like to generate automatic calls from a python program (let's > call it myprog.py), play a sound file and retrieve the digit pressed by > the callee into the initial program (myprog.py). > I used the pyst package (through a small python programm that we can > call automatic.py) to test generation of calls with Originate and read > the sound file. It works well !! > Thanks to Michael Fletcher for his work. > > 1) Could somebody explain me what python function I can use to run the > automatic.py program from myprog.py ? > It seems that the os.exec function is not the good one. Right ? > I suppose that I will have to use sys.arg to pass the tel number from > myprog.py to automatic.py. You can just connect to the manager from your AGI script, no need to execute an external program. You could also execute an external program as well if you really feel you need to. > 2) How can I retrieve the digit pressed by the callee into myprog.py ? > Should I use the Read Asterisk function and how ? > I wonder if I have to run automatic.py in a thread from myprog.py. You would need to execute the Originate action passing 'context', 'exten', and 'priority' as arguments which would cause the originated call to begin execution at the specified context, exten, and priroity. At that location in the dialplan you would collect any digits pressed. If you wanted to relay that information back to your original script you could use the UserEvent application to generate a manager event. > 3) Just for info, I would like to understand the line ' variables = > {'WaitTime':'45'}, ' in the example provided by Michael in his site > http://blog.vrplumber.com/1274. That line will set the channel variable 'WaitTime' to the value '45' for the originated channel. The 'variables' parameter accepts a dictionary of name and value pairs to set as channel variables on the originated channel. -- Matthew Nicholson Digium |