From: Dax R. <ra...@gm...> - 2005-01-11 15:26:23
|
Hello, seems to be a bug. try using agi.py and put something like #!/usr/bin/env python import asterisk.agi agi = asterisk.agi.AGI() mydigit = agi.get_data('demo-congrats',timeout=5000) #do no input anything, mydigit now has a value "UNDEFINED" ! agi.say_digits(mydigit) sys.exit(0) call function get_data and not input anything. then call say_digits will throw an exception because of the UNDEFINED value I can't think of a good fix, since if I put an "if" condition in function get_data something like if res == "UNDEFINED": res = '' say_digits will now issue an agi command say digits "" "" which will also throw an exception Dax |
From: Matthew A. N. <mni...@di...> - 2005-01-11 15:46:13
|
Dax Reyes wrote: > Hello, > > seems to be a bug. > > try using agi.py and put something like > > #!/usr/bin/env python > > import asterisk.agi > agi = asterisk.agi.AGI() > > mydigit = agi.get_data('demo-congrats',timeout=5000) > > #do no input anything, mydigit now has a value "UNDEFINED" ! > agi.say_digits(mydigit) > sys.exit(0) > > > call function get_data and not input anything. > then call say_digits > will throw an exception because of the UNDEFINED value > > I can't think of a good fix, since if I put an "if" condition in > function get_data something like > > if res == "UNDEFINED": > res = '' > > say_digits will now issue an agi command > say digits "" "" > > which will also throw an exception > > I wouldn't call that a bug. Maybe it should be handled differently, but that is what asterisk returns to us. -- Matthew A. Nicholson Digium |
From: Dax R. <ra...@gm...> - 2005-01-12 03:35:19
|
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 On Tue, 11 Jan 2005 09:46:09 -0600, Matthew A. Nicholson <mni...@di...> wrote: > Dax Reyes wrote: > > Hello, > > > > seems to be a bug. > > > > try using agi.py and put something like > > > > #!/usr/bin/env python > > > > import asterisk.agi > > agi = asterisk.agi.AGI() > > > > mydigit = agi.get_data('demo-congrats',timeout=5000) > > > > #do no input anything, mydigit now has a value "UNDEFINED" ! > > agi.say_digits(mydigit) > > sys.exit(0) > > > > > > call function get_data and not input anything. > > then call say_digits > > will throw an exception because of the UNDEFINED value > > > > I can't think of a good fix, since if I put an "if" condition in > > function get_data something like > > > > if res == "UNDEFINED": > > res = '' > > > > say_digits will now issue an agi command > > say digits "" "" > > > > which will also throw an exception > > > > > > I wouldn't call that a bug. Maybe it should be handled differently, but that is > what asterisk returns to us. > > -- > Matthew A. Nicholson > Digium > > ------------------------------------------------------- > The SF.Net email is sponsored by: Beat the post-holiday blues > Get a FREE limited edition SourceForge.net t-shirt from ThinkGeek. > It's fun and FREE -- well, almost....http://www.thinkgeek.com/sfshirt > _______________________________________________ > Pyst-users mailing list > Pys...@li... > https://lists.sourceforge.net/lists/listinfo/pyst-users > dax |
From: Matthew A. N. <mni...@di...> - 2005-01-12 15:21:08
|
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 |
From: Dax R. <ra...@gm...> - 2005-01-16 05:54:06
|
On Wed, 12 Jan 2005 09:21:04 -0600, Matthew A. Nicholson <mni...@di...> wrote: > <snipped> > Sounds reasonable, go ahead and send a patch. Also if you see any other cases > like this send those as well. ok, I have uploaded the patch here. http://sourceforge.net/tracker/index.php?func=detail&aid=1102447&group_id=76162&atid=546274 > > -- > Matthew A. Nicholson > Digium > <snipped> Dax |
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 |