VoIP Mailing List Archives
Mailing list archives for the VoIP community |
|
View previous topic :: View next topic |
Author |
Message |
darcy at Vex.Net Guest
|
Posted: Wed Jan 06, 2016 12:20 pm Post subject: [asterisk-users] No joy with my first AGI Python script |
|
|
It's very simple but it doesn't work. Here's the entire script.
#! /usr/bin/python
import sys
env = {}
def comm(cmd):
sys.stdout.write(cmd.strip() + '\n')
sys.stdout.flush()
return sys.stdin.readline().strip()
while 1:
line = sys.stdin.readline().strip()
if line == '': break
key,data = line.split(':')
if key[:4] == 'agi_':
key = key.strip()[4:]
data = data.strip()
if key: env[key] = data
#comm("Verbose(0,pyast: %s)" % sys.argv)
comm('SAY NUMBER 123 ""')
sys.stderr.write("AGI Environment Dump:\n");
for key in env.keys():
sys.stderr.write(" -- %s = %s\n" % (key, env[key]))
sys.stderr.flush()
The extension is;
exten => *22,1,Verbose(0,${CHANNEL(peername)} calling 22 TEST)
same => n,AGI(/home/darcy/pyast,Hello world)
same => n,Hangup
What happens when I dial it is that the dialplan Verbose statement runs
but nothing else is logged and the number is not said. When I turn on
AGI debugging I get this:
... (a bunch of agi_ variables)
<SIP/darcy-0000000d>AGI Tx >> agi_arg_1: Hello world
<SIP/darcy-0000000d>AGI Tx >>
<SIP/darcy-0000000d>AGI Rx << SAY NUMBER 123 ""
<SIP/darcy-0000000d>AGI Tx >> 200 result=0
There is a delay between the last Rx and Tx suggesting that it thinks
that the numbers are being played but I don't hear them. Also, the
output to stderr does not appear in the logs.
Here is my environment:
- Asterisk 11.20.0
- NetBSD 7.0
- Python 3.4
Thanks in advance for any help or suggestions.
--
D'Arcy J.M. Cain
System Administrator, Vex.Net
http://www.Vex.Net/ IM:darcy@Vex.Net
VoIP: sip:darcy@Vex.Net
--
_____________________________________________________________________
-- Bandwidth and Colocation Provided by http://www.api-digital.com --
New to Asterisk? Join us for a live introductory webinar every Thurs:
http://www.asterisk.org/hello
asterisk-users mailing list
To UNSUBSCRIBE or update options visit:
http://lists.digium.com/mailman/listinfo/asterisk-users |
|
Back to top |
|
|
asterisk.org at sedwar... Guest
|
Posted: Wed Jan 06, 2016 3:53 pm Post subject: [asterisk-users] No joy with my first AGI Python script |
|
|
On Wed, 6 Jan 2016, D'Arcy J.M. Cain wrote:
Quote: | It's very simple but it doesn't work. Here's the entire script.
#! /usr/bin/python
import sys
env = {}
def comm(cmd):
sys.stdout.write(cmd.strip() + '\n')
sys.stdout.flush()
return sys.stdin.readline().strip()
while 1:
line = sys.stdin.readline().strip()
if line == '': break
key,data = line.split(':')
if key[:4] == 'agi_':
key = key.strip()[4:]
data = data.strip()
if key: env[key] = data
#comm("Verbose(0,pyast: %s)" % sys.argv)
comm('SAY NUMBER 123 ""')
sys.stderr.write("AGI Environment Dump:\n");
for key in env.keys():
sys.stderr.write(" -- %s = %s\n" % (key, env[key]))
sys.stderr.flush()
The extension is;
exten => *22,1,Verbose(0,${CHANNEL(peername)} calling 22 TEST)
same => n,AGI(/home/darcy/pyast,Hello world)
same => n,Hangup
What happens when I dial it is that the dialplan Verbose statement runs
but nothing else is logged and the number is not said. When I turn on
AGI debugging I get this:
... (a bunch of agi_ variables)
<SIP/darcy-0000000d>AGI Tx >> agi_arg_1: Hello world
<SIP/darcy-0000000d>AGI Tx >>
<SIP/darcy-0000000d>AGI Rx << SAY NUMBER 123 ""
<SIP/darcy-0000000d>AGI Tx >> 200 result=0
There is a delay between the last Rx and Tx suggesting that it thinks
that the numbers are being played but I don't hear them. Also, the
output to stderr does not appear in the logs.
Here is my environment:
- Asterisk 11.20.0
- NetBSD 7.0
- Python 3.4
|
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.
1) Is the space after the 'she-bang' significant?
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.
3) If you dump your AGI environment before 'say number' do you get a
different outcome?
4) Any chance the 'digits' directory is missing or that your channel
language is set weird? Does the saynumber() dialplan application work?
5) Can you play any audio to the channel? Does playback(demo-congrats)
work?
(That was my last straw to grasp -- need another cup of tea.)
--
Thanks in advance,
-------------------------------------------------------------------------
Steve Edwards sedwards@sedwards.com Voice: +1-760-468-3867 PST
--
_____________________________________________________________________
-- Bandwidth and Colocation Provided by http://www.api-digital.com --
New to Asterisk? Join us for a live introductory webinar every Thurs:
http://www.asterisk.org/hello
asterisk-users mailing list
To UNSUBSCRIBE or update options visit:
http://lists.digium.com/mailman/listinfo/asterisk-users |
|
Back to top |
|
|
darcy at Vex.Net Guest
|
Posted: Wed Jan 06, 2016 11:22 pm Post subject: [asterisk-users] No joy with my first AGI Python script |
|
|
On Wed, 6 Jan 2016 12:19:51 -0800 (PST)
Steve Edwards <asterisk.org@sedwards.com> wrote:
Quote: | 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.
Quote: | 1) Is the space after the 'she-bang' significant?
|
No. It does the same whether it is there or not.
Quote: | 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.
Quote: | 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.
Quote: | 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.
Quote: | 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.
Quote: | (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@Vex.Net
VoIP: sip:darcy@Vex.Net
--
_____________________________________________________________________
-- Bandwidth and Colocation Provided by http://www.api-digital.com --
New to Asterisk? Join us for a live introductory webinar every Thurs:
http://www.asterisk.org/hello
asterisk-users mailing list
To UNSUBSCRIBE or update options visit:
http://lists.digium.com/mailman/listinfo/asterisk-users |
|
Back to top |
|
|
darcy at Vex.Net Guest
|
Posted: Wed Jan 06, 2016 11:34 pm Post subject: [asterisk-users] No joy with my first AGI Python script |
|
|
On Wed, 6 Jan 2016 23:21:44 -0500
"D'Arcy J.M. Cain" <darcy@Vex.Net> wrote:
Quote: | 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.
|
Turns out to be related to AGI after all. I created a new test with
Playback, SayNumber and SayPhonetic and everything worked fine so the
issue was something else.
Aha! Everything works fine. I just forgot to answer the phone.
I think I need a session with the Clue-By-Four.
--
D'Arcy J.M. Cain
System Administrator, Vex.Net
http://www.Vex.Net/ IM:darcy@Vex.Net
VoIP: sip:darcy@Vex.Net
--
_____________________________________________________________________
-- Bandwidth and Colocation Provided by http://www.api-digital.com --
New to Asterisk? Join us for a live introductory webinar every Thurs:
http://www.asterisk.org/hello
asterisk-users mailing list
To UNSUBSCRIBE or update options visit:
http://lists.digium.com/mailman/listinfo/asterisk-users |
|
Back to top |
|
|
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|