|
From: Joel S. <jo...@jo...> - 2015-01-22 20:27:55
|
Hi Italo,
This is what I see in the logs:
[2015-01-22 20:59:28] VERBOSE[4765][C-00002aab] res_agi.c: --
Launched AGI Script /var/lib/asterisk/agi-bin/GetRegServerExt.py
[2015-01-22 20:59:28] VERBOSE[4765][C-00002aab] res_agi.c:
GetRegServerExt.py,sipusers,159100: ('dynamic', 'friend', 'sip06')
[2015-01-22 20:59:29] VERBOSE[4765][C-00002aab] res_agi.c: --
<SIP/XION-00003003>AGI Script GetRegServerExt.py completed, returning
0
If the GetRegServerExt.py for any reason fails, I also see:
[2015-01-22 20:59:29] VERBOSE[4765][C-00002aab] res_agi.c: --
<SIP/XION-00003003>AGI Script GetRegServerExt.py completed, returning
0
What I am trying is to set the "returning" code, for example:
[2015-01-22 20:59:29] VERBOSE[4765][C-00002aab] res_agi.c: --
<SIP/XION-00003003>AGI Script GetRegServerExt.py completed, returning
16
But I can't seem to find the way to do so.
Regards,
Joel.
--
Joel Serrano De Castro
Cell: +34 639 03 13 53
E-Mail: jo...@jo...
On Wed, Jan 21, 2015 at 11:08 PM, Ítalo Rossi <ita...@gm...> wrote:
> Check the value of ${AGISTATUS} after Agi() in dialplan. You can also set
> variable inside the Agi and check the content after execution
>
> Em 21/01/2015 15:55, "Joel Serrano" <jo...@jo...> escreveu:
>>
>> Hi everybody.
>>
>> This is my first post to the list, I am trying pyst and so far so good :)
>>
>> One thing I don't understand:
>>
>> No matter whatever I do, I always see in asterisk log:
>>
>> AGI Script GetRegServerExt.py completed, returning 0
>>
>> How can I change the returning code to something else?
>>
>> This is my GetRegServerExt.py:
>>
>>
>> #!/usr/bin/env python
>> # coding: latin-1
>>
>> import sys
>> import MySQLdb
>> from asterisk.agi import *
>>
>> mysqlhost = "localhost"
>> mysqluser = "test"
>> mysqlpass = "test"
>> mysqldatabase = "test"
>> mysqlsock = "/var/run/mysqld/mysql.sock"
>>
>> table = sys.argv[1]
>> extension = sys.argv[2]
>>
>> myagi = AGI()
>> try:
>> conn = MySQLdb.connect(host=mysqlhost, unix_socket=mysqlsock,
>> user=mysqluser, passwd=mysqlpass, db=mysqldatabase)
>> conn.autocommit(True)
>> cur = conn.cursor()
>> query = "SELECT host,type,regserver FROM %s WHERE name='%s'" %
>> (table, extension)
>> cur.execute(query)
>> sqldata = cur.fetchall()
>> cur.close()
>> conn.close()
>> except (MySQLdb.OperationalError, MySQLdb.DataError,
>> MySQLdb.ProgrammingError), message:
>> myagi.verbose("[AGI-ERROR] - MySQL Error %s: %s" % (message[0],
>> message[1]))
>>
>> if len(sqldata) == 1:
>> myagi.set_variable('host_extension', sqldata[0][0])
>> myagi.set_variable('type_extension', sqldata[0][1])
>> myagi.set_variable('reg_server', sqldata[0][2])
>> else:
>> myagi.verbose("AGI Python: ERROR")
>>
>>
>> I have tried different ways of forced errors, but still return code is 0.
>>
>> In fact, If I force MySQL errors (as wrong password, etc.), return code is
>> 0
>>
>> How can I send back to asterisk custom return codes so I know the real
>> result of the AGI execution?
>>
>> Thank you all in advanced.
>>
>> J.
>>
>>
>> ------------------------------------------------------------------------------
>> New Year. New Location. New Benefits. New Data Center in Ashburn, VA.
>> GigeNET is offering a free month of service with a new server in Ashburn.
>> Choose from 2 high performing configs, both with 100TB of bandwidth.
>> Higher redundancy.Lower latency.Increased capacity.Completely compliant.
>> http://p.sf.net/sfu/gigenet
>> _______________________________________________
>> Pyst-users mailing list
>> Pys...@li...
>> https://lists.sourceforge.net/lists/listinfo/pyst-users
>
>
> ------------------------------------------------------------------------------
> New Year. New Location. New Benefits. New Data Center in Ashburn, VA.
> GigeNET is offering a free month of service with a new server in Ashburn.
> Choose from 2 high performing configs, both with 100TB of bandwidth.
> Higher redundancy.Lower latency.Increased capacity.Completely compliant.
> http://p.sf.net/sfu/gigenet
> _______________________________________________
> Pyst-users mailing list
> Pys...@li...
> https://lists.sourceforge.net/lists/listinfo/pyst-users
>
|