[Freeswitch-users] Need help using api_hangup_hook and session_in_hangup_hook

Herman Griffin herman.griffin at gmail.com
Sat Jan 7 20:28:30 MSK 2012


Hello,

I'm using the api_hangup_hook and session_in_hangup variables with a
pyrun. How do I access the session object from inside the python
module?

---------------------------------
Here are some logs :

Dialplan: sofia/external/3105795721 at 72.37.252.18 Absolute Condition [emergency]
Dialplan: sofia/external/3105795721 at 72.37.252.18 Action
set(session_in_hangup_hook=true)
Dialplan: sofia/external/3105795721 at 72.37.252.18 Action
set(api_hangup_hook=pyrun emergency.hangup)
Dialplan: sofia/external/3105795721 at 72.37.252.18 Absolute Condition [emergency]
.
.
2012-01-07 09:21:57.693488 [DEBUG] mod_python.c:281 Call python script
2012-01-07 09:21:57.693488 [DEBUG] mod_python.c:284 Finished calling
python script
2012-01-07 09:21:57.693488 [ERR] mod_python.c:293 Error calling python script
2012-01-07 09:21:57.693488 [ERR] mod_python.c:164 Python Error by
calling script "emergency.hangup": <type 'exceptions.NameError'>
Message: global name 'session' is not defined
Exception: None

Traceback (most recent call last)
	File: "/usr/local/freeswitch/scripts/python/emergency/hangup.py",
line 34, in runtime



----------------------------------------------------------
Here is the simple script

python module emergency.hangup:

from freeswitch import *

def runtime(arg):
    consoleLog("info", print(dir(session)))



Thanks,
Herman



Join us at ClueCon 2011 Aug 9-11, 2011
More information about the FreeSWITCH-users mailing list