|
From: Ítalo R. <ita...@gm...> - 2015-01-21 22:08:21
|
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
>
|