[SR-Users] python_exec and parameters

gmele giovanni.mele at nagra.com
Wed Feb 8 09:47:21 CET 2017


Hello,

in our Kamailio, we are using python_exec to execute script used to send
push notifications to Google or Apple.

Currenty, the method we call only accepts the message as parameter. We then
extract from the message the Call Id, to URI and from URI. 

Here is the python method signature:

*def SendPushNotification(self, msg)*

To extract the toUri and fromUri (and remove the sip:), we use python regex
: 

*uriPattern=re.compile(".*sips?:(.+@[^>;]+)")*

This is working well 99% of the time, except sometimes (we don't know why)
where we get the error:

*logger_LM_ERR(): Exception occurred: Traceback (most recent call last):
File "mypythonExample.py", line XXX, in SendPushNotification    
requestUri = self.ExtractURIFromHeader(msg.getHeader("to"))
File "mypythonExample.py", line XXX, in ExtractURIFromHeader    
m= self.uriPattern.match(header);
TypeError: an integer is required*

We tried to analyze the cause of this error, but we didn't find any problem
with the message itself (the message is complete, with the *to *and *from
*correctly filled).

So, to avoid using the python regex, we have decided to pass parameters to
the python script (callId, from and to URI):

*def SendPushRequest(self, msg, fromUri, toUri, callid)*

But it seems python_exec doesn't support more than 2 parameters ($mb and
another one). Is this exact? If this is the case, how can we pass several
parameters from kamailio.cfg? 

Thx for your help.

Regards

Giovanni





--
View this message in context: http://sip-router.1086192.n5.nabble.com/python-exec-and-parameters-tp155803.html
Sent from the Users mailing list archive at Nabble.com.



More information about the sr-users mailing list