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 |