nhtdata / pystrix

Automatically exported from code.google.com/p/pystrix
GNU Lesser General Public License v3.0
0 stars 0 forks source link

GetData timeout raises an AGINoResultError #9

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Use the GetData method with a timeout: 
response = agi.execute(pystrix.agi.core.GetData('enter_pin', 5000, 4))

2. Enter nothing and wait for the timeout to expire

What is the expected output? 
Asterisk responds with 'result= (timeout)' so I want '(timeout)' in the 
response.

What do you see instead?
This raises an 'AGINoResultError' because of the space between the result and 
the value

What version of the product are you using? On what operating system?
Asterisk 1.8.25.0
pystrix latest
Debian 7

Please provide any additional information below.
I changed the regex in agi_core.py on line 45 to:
_RE_KV = 
re.compile(r'(?P<key>\w+)=[\s]?(?P<value>[^\s]+)(?:\s+\((?P<data>.*)\))?') 
#Matches Asterisk's key-value response-pairs

With this change it works as expected and I can call GetData again. I tried 
catching the exception and calling GetData but that doesn't seem to work.

Original issue reported on code.google.com by rok...@gmail.com on 29 Jul 2014 at 10:19

GoogleCodeExporter commented 9 years ago
Thanks for bringing this up, rokfan.

The regex you provided isn't quite what I've committed, since the problem here 
is really that different versions of Asterisk do vastly inconsistent things (if 
you look through its code, pretty much every AMI/AGI string it emits is coded 
locally in its modules, rather than using a standard template). The last commit 
was meant to address this issue, reported via e-mail, but there wasn't enough 
information to catch the case you've submitted.

Please test the change and let me know if it works for you.

-Neil

Original comment by red.hamsterx on 29 Jul 2014 at 3:29

GoogleCodeExporter commented 9 years ago
The change works for me. Thanks for the fast response!

Original comment by rok...@gmail.com on 29 Jul 2014 at 4:02