문제

I have this dial plan and i want to handle the dialed number using python. But its not working any idea?

default.xml (dialplan):

<extension name="Run Python">
  <condition field="destination_number" expression="^(?:\+|00)(\d+)$">
    <action application="set" data="effective_caller_id_number=${caller_id_number}"/>
    <action application="python" data="a" />    
 </condition>
</extension>

a.py (main dialing number router):

import freeswitch
def handler(session, args):
    consoleLog("INFO", "print this please >>>>>>>>>>>>>>!>>>>>>>>>>>>>>>>>>>>!>")

Not working, when call is made:

2013-09-13 22:55:49.645980 [NOTICE] mod_python.c:212 Invoking py module: a
2013-09-13 22:55:49.645980 [DEBUG] mod_python.c:281 Call python script 
2013-09-13 22:55:49.645980 [DEBUG] mod_python.c:284 Finished calling python script 
2013-09-13 22:55:49.645980 [ERR] mod_python.c:293 Error calling python script
2013-09-13 22:55:49.645980 [ERR] mod_python.c:164 Python Error by calling script "a": <type 'exceptions.NameError'>
Message: global name 'consoleLog' is not defined
Exception: None

Traceback (most recent call last)
    File: "/usr/local/freeswitch/scripts/a.py", line 3, in handler
도움이 되었습니까?

해결책 2

Python is telling you what the problem is: there's no such thing as consoleLog. Is this something defined in the freeswitch module? If so, you wantfreeswitch.consoleLog.

다른 팁

Try

freeswitch.consoleLog("info","your debug string")

You can also use

session.execute("log", ">>>>>>>>>>>>>>>>>>");
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top