[SR-Users] FW: App_python Module

Muhammad Nasir Bhutta mbhutta at btlnet.co.uk
Wed Nov 2 06:02:06 CET 2011


Thanks Daniel for your help .. I have downloaded the new version yesterday and it has the same path.. However, I run a script to find out the Python Interpreter information and it now loads the things fine.. There is no error.. 

As, I mentioned in my other email, that I am trying to execute the functions like python_exec() in request_route block, but it does not give any error and it does not show any output as well.. 

As, we start kamailio, it starts the kamailio and control is transferred to the OS.. I have checked in the handler.py script and it is exporting the LM_ERR function from Routing module and trying to print some extracted information from the SIP message .. But, I can't see any output when I run it.. How can I observe the output of the python script .. 

I have tried to run another python script in which a new server is created which listens for clients messages on some other port but, still I can't see control being transferred to Python server program.. instead Kamailio thread halts and it does not display the message Kamailio started but stops before that .. 

The other thing useful will be to tell some about modparam() parameter.. I have tried to use it for mod_init and child_init functions but it asks to use mod_register function instead.. 

Can you please help with the email address of the person who have written this app_python module .. 

Many thanks for your consideration and help.. 

Kind Regards,
Nasir
________________________________________
From: Daniel-Constantin Mierla [miconda at gmail.com]
Sent: 01 November 2011 22:49
To: SIP Router - Kamailio (OpenSER) and SIP Express Router (SER) - Users Mailing List
Cc: Muhammad Nasir Bhutta
Subject: Re: [SR-Users] FW: App_python Module

Some update -- there was a new patch just applied to the module to fix the path of loading python script. You have to take latest version from GIT, any of branches master, 3,2 or 3.2 work -- you find on the wiki pages of kamailio.org (see right sidebar) some tutorials about how to install from GIT 3.1 or 3.2 if you are not already familiar with.

Cheers,
Daniel

On 11/1/11 11:21 PM, Daniel-Constantin Mierla wrote:
Hello,

I am not an user of this module, I tried to fix some issues of this module in the past purely based on C programming, so I add here some comments.

On 11/1/11 2:54 PM, Muhammad Nasir Bhutta wrote:
Hi,
I am a new user of Kamailio, and I am working on enabling the App_Python module in Kamailio..

While searching on google, I came acroos your email on the forum where you people are trying to patch the App_Python module..
There was a patch I applied in the past, like few month ago. I think there is another on our issue tracker that seemed to be the same, I will double check it soon.

I am wandering whether you can please help a bit ..


1-      How to do the configuration to enable the App_python module ? .. At the moment, I am just adding the following line in the configuration file, loadmodule “app_python.so” and just correcting the path to handler.py to the right directory in the code for script path.

2-      What output we should expect when we enable the app_python module ? .. I have seen the handler.py script written in python which is printing some sip message information ? ..

3-      How the SIP Message structure is being passed to handler.py ? … How we are accessing the Router module in handler.py script and LM_ERR function from Kamailio ? ..
Any help in this regards shall be really helpful .. In any case, whether you can solve this issue or not, please reply the email..
I guess that once your python script is loaded properly, you can use in kamailio.cfg the function python_exec() to execute functions from your python script. LM_ERR is unlikely to get it executed from python script since it is a C define (unless it was exported explicitly by app_python module), but you can probably execute any function exported by kamailio modules.

It will help you to look at C code of app_python module to see what and how you can execute from Kamailio, unfortunately this module is not very documented, I am not the author of it, so I cannot help you more that this for the moment.

Maybe it will help to look at perl or app_lua modules, they have better documentation with some examples that can get you started, but of course it is not python, so you have to use perl or lua to build your script.

Cheers,
Daniel


--
Daniel-Constantin Mierla -- http://www.asipto.com
Kamailio Advanced Training, Dec 5-8, Berlin: http://asipto.com/u/kat
http://linkedin.com/in/miconda -- http://twitter.com/miconda



_______________________________________________
SIP Express Router (SER) and Kamailio (OpenSER) - sr-users mailing list
sr-users at lists.sip-router.org<mailto:sr-users at lists.sip-router.org>
http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-users



--
Daniel-Constantin Mierla -- http://www.asipto.com
Kamailio Advanced Training, Dec 5-8, Berlin: http://asipto.com/u/kat
http://linkedin.com/in/miconda -- http://twitter.com/miconda





More information about the sr-users mailing list