py-asterisk icon indicating copy to clipboard operation
py-asterisk copied to clipboard

Command() fails with Asterisk 14.5

Open alexis-via opened this issue 9 years ago • 1 comments

With py-Asterisk 0.5.14 and Asterisk 14.5.0:

root@xs ~ # python
Python 2.7.9 (default, Jun 29 2016, 13:08:31) [GCC 4.9.2] on linux2 Type "help", "copyright", "credits" or "license" for more information.

from Asterisk import Manager m = Manager.Manager(('127.0.0.1', 5038), 'xivo_munin_user', 'xxxxxxx') m.Command('sip reload') Traceback (most recent call last): File "", line 1, in File "/usr/local/lib/python2.7/dist-packages/Asterisk/Manager.py", line 520, in Command return self._translate_response(self.read_response(id))['Lines'] KeyError: 'Lines'

Note that the Command has been successfully executed with Asterisk (according to a tcpdump) ; the crash is just in the parsing of the answer.

If I modify /usr/local/lib/python2.7/dist-packages/Asterisk/Manager.py line 520 and remove ['Lines'] at the end, it works well: 20:58 root@xs ~ # python Python 2.7.9 (default, Jun 29 2016, 13:08:31) [GCC 4.9.2] on linux2 Type "help", "copyright", "credits" or "license" for more information.

from Asterisk import Manager m = Manager.Manager(('127.0.0.1', 5038), 'xivo_munin_user', 'xxxxxxxxxx') m.Command('sip reload') {u'Output': '', u'Message': u'Command output follows', u'Response': u'Success'}

alexis-via avatar Jul 14 '17 19:07 alexis-via

Hi, I patched and released the code to handle a case where 'Lines' would be missing more safely. Therefore, can you send me a dump of the answer ?

Jean

jeansch avatar Aug 04 '17 18:08 jeansch