|
From: Dax R. <ra...@gm...> - 2005-01-18 06:11:29
|
Seems its better to 'trap' the "UNDEFINED" in get_data and raise an AGIException
Below is the patch.
--- pyst-0.0.4rc9.orig/asterisk/agi.py 2004-12-14 09:30:25.000000000 +0800
+++ pyst-0.0.4rc9/asterisk/agi.py 2005-01-18 11:26:02.701385792 +0800
@@ -1,4 +1,4 @@
-#!/usr/bin/env python2
+#!/usr/bin/env python
"""agi
@@ -302,6 +302,8 @@
"""
result = self.execute('get data', filename, timeout, max_digits)
res, value = result['result']
+ if res == 'UNDEFINED':
+ raise AGIException("res = %s : Timeout without receiving data" %(res
))
return res
On Wed, 12 Jan 2005 09:21:04 -0600, Matthew A. Nicholson
<mni...@di...> wrote:
> Dax Reyes wrote:
> > I get the following on asterisk console when I
> > call get_data
> > let it timeout
> > then call say_digits.
> >
> > COMMAND: get data demo-congrats 5000 255
> > -- Playing 'demo-congrats' (language 'en')
> > RESULT_LINE: 200 result= (timeout)
> > RESULT_DICT: {'result': ('UNDEFINED', '')}
> > COMMAND: say digits "UNDEFINED" ""
> > RESULT_LINE: 520-Invalid command syntax. Proper usage follows:
> > Traceback (most recent call last):
> > File "/usr/local/share/asterisk/agi-bin/agi.py", line 516, in ?
> > agi.say_digits(mydigit)
> > File "/usr/local/share/asterisk/agi-bin/agi.py", line 231, in say_digits
> > res = self.execute('say digits', digits, escape_digits)['result'][0]
> > File "/usr/local/share/asterisk/agi-bin/agi.py", line 63, in execute
> > return self.get_result()
> > File "/usr/local/share/asterisk/agi-bin/agi.py", line 111, in get_result
> > raise AGIException(code, usage)
> > __main__.AGIException: (520, '520-Invalid command syntax. Proper usage follows:
> >
> > In order to avoid 520 AGIException for this situation:
> >
> > when agi asks for some input (get_data) then timeout without getting
> > any ( thus getting a result = {result:('UNDEFINED','')} ) and later
> > "playing/saying" the digits/number with digits = `"UNDEFINED"'
> >
> > I have added something like
> >
> > if digits = `"UNDEFINED"': return ''
> >
> > in function say_digits
> >
>
> Sounds reasonable, go ahead and send a patch. Also if you see any other cases
> like this send those as well.
>
> --
> Matthew A. Nicholson
> Digium
Dax
|