bug ChanVariable for asterisk 11 and early
romkazor opened this issue · comments
Roman Pertsev commented
Hello, in some early version of asterisk ChanVariable looks a little differently, and event parser show only last ChanVariable (only CDR(dst)=102). In later version of asterisk event parser show dict of ChanVariable. How can I fix this?
Asterisk 11 (bug)
Event: Hangup
...
ChanVariable(Local/101@from-internal-00000023;1): CDR(dcontext)=from-internal
ChanVariable(Local/101@from-internal-00000023;1): CDR(dst)=101
ChanVariable(Local/102@from-internal-00000023;2): CDR(dcontext)=from-internal
ChanVariable(Local/102@from-internal-00000023;2): CDR(dst)=102
Asterisk 12+ (ok)
Event: Hangup
...
ChanVariable: CDR(dcontext)=from-internal
ChanVariable: CDR(dst)=101
DestChanVariable: CDR(dcontext)=from-internal
DestChanVariable: CDR(dst)=102
Roman Pertsev commented
I wrote ugly fix, but it works, in event.py after 39 string:
before:
try:
(key, value) = lines[i].split(': ', 1)
if key in Event.parsers:
after:
try:
chanvaris = 'ChanVariable'
if lines[i].find('Channel: ') != -1:
channel = lines[i].split(': ')[1]
if lines[i].find('): ') != -1:
chanvar = lines[i].split('): ')[0].split('(')[1]
if chanvar != channel:
chanvaris = 'DestChanVariable'
if chanvaris != 'DestChanVariable':
(key, value) = re.sub(r'\([^)]*\)\:', ':', lines[i]).split(': ', 1)
else:
(key, value) = re.sub(r'ChanVariable\([^)]*\)\:', 'DestChanVariable:', lines[i]).split(': ', 1)
if key in Event.parsers:
Éttore Leandro Tognoli commented
I will think about it and try to do something.
Probabily I will delay, I'm busy with the work, but as soon as possible I will work at this.
Thanks for the bug report and for the suggestion.