[asterisk-users] No joy with my first AGI Python script

D'Arcy J.M. Cain darcy at Vex.Net
Wed Jan 6 22:21:44 CST 2016


On Wed, 6 Jan 2016 12:19:51 -0800 (PST)
Steve Edwards <asterisk.org at sedwards.com> wrote:
> In no particular order (except #0):
> 
> 0) Use an existing Python library. Nobody gets it right the first
> time. I wrote my C library 100 years ago, so I don't remember all the
> specifics of the AGI protocol.

Are you talking about pyst?  I guess but I am a firm believer in
understanding the technology before I use it.  I learned programming by
depositing bits on an Altair S-100 bus.  Even though I will probably
never get close to that level again I think it made a good foundation.

> 1) Is the space after the 'she-bang' significant?

No.  It does the same whether it is there or not.

> 2) Your 'sys.stderr.write' may be violating the AGI protocol. Writing
> to stdout definitely does. I don't remember what writing to stderr
> does.

I got that from some example code I found.  I removed it but nothing
changed.

> 3) If you dump your AGI environment before 'say number' do you get a 
> different outcome?

Nope.  That was actually where I started.  I moved it to the end just
in case it was causing a problem.

> 4) Any chance the 'digits' directory is missing or that your channel 
> language is set weird? Does the saynumber() dialplan application work?

OK, it doesn't.  Shouldn't I see an error in the logs though?  It
pauses just like the AGI script but nothing is said and no errors are
printed.

> 5) Can you play any audio to the channel? Does
> playback(demo-congrats) work?

Yes, that works.  Also, "playback(digits/4&digits/5&digits/6)" works
which tells me that the digits directory is where it is supposed to
be.  Another data point, "SayPhonetic(hello)" also does not work but
there is silence as long as would expect the audio to last, same as
SayNumber.

> (That was my last straw to grasp -- need another cup of tea.)

Interestingly this led me down a different path.  I added this to my
script - comm('SET VARIABLE PYAST "hello world"') and displayed the 
varible in my dialplan and that worked.  Saying a number was just a
way to test the AGI.  I didn't really need audio for my current 
project. Now that I know that I can set variables I can continue.

However, I sure would like to know why SayWhatever isn't working.  I
will start a new thread for that issue.

Thanks for the pointers.

-- 
D'Arcy J.M. Cain
System Administrator, Vex.Net
http://www.Vex.Net/ IM:darcy at Vex.Net
VoIP: sip:darcy at Vex.Net



More information about the asterisk-users mailing list