<html>
<head>
<meta content="text/html; charset=utf-8" http-equiv="Content-Type">
</head>
<body bgcolor="#FFFFFF" text="#000000">
<p><br>
</p>
<br>
<div class="moz-cite-prefix">On 09/02/2017 16:47, Konstantin M.
wrote:<br>
</div>
<blockquote
cite="mid:CAEYtTzdS+TQxP7jyyKPmwdxXtSKXY1=0bax+qS+uvrvU=DCWow@mail.gmail.com"
type="cite">
<div dir="ltr">
<div>
<div>
<div>That's correct, it accepts only one parameter for now.<br>
</div>
After many years our company has switched to kamailio, I'm
actively working on new version of app_python, more flexible
and usable than current one, many new features...<br>
</div>
I'm not ready to push new changes to current module due to raw
alpha and unstable work.<br>
</div>
</div>
</blockquote>
<br>
If you haven't seen it, note the addition of support for kemi in the
app_python. That should be preserved.<br>
<blockquote
cite="mid:CAEYtTzdS+TQxP7jyyKPmwdxXtSKXY1=0bax+qS+uvrvU=DCWow@mail.gmail.com"
type="cite">
<div dir="ltr"><br>
Right now. as workaround you can pass something like
$_s($fu!!$tu) and then in python parse them with from_user,
to_user = $param1.split("!!")<br>
</div>
</blockquote>
<br>
Quickly looking in the source code, the function doesn't evaluate
the variables in the parameters. I will try to fix it soon.<br>
<br>
Cheers,<br>
Daniel<br>
<br>
<blockquote
cite="mid:CAEYtTzdS+TQxP7jyyKPmwdxXtSKXY1=0bax+qS+uvrvU=DCWow@mail.gmail.com"
type="cite">
<div class="gmail_extra"><br>
<div class="gmail_quote">2017-02-09 11:31 GMT+03:00
Daniel-Constantin Mierla <span dir="ltr"><<a
moz-do-not-send="true" href="mailto:miconda@gmail.com"
target="_blank">miconda@gmail.com</a>></span>:<br>
<blockquote class="gmail_quote" style="margin:0 0 0
.8ex;border-left:1px #ccc solid;padding-left:1ex">Hello,<br>
<br>
not very familiar with the app_python initial design, but
when I added<br>
kemi support in it for kamailio 5.0, I think I noticed the
limitation of<br>
1 extra parameter. Probably you can encode your parameters
in comma<br>
separated value, so you can parse it easier in the python
script, as<br>
opposite to parsing the entire message buffer.<br>
<br>
An alternative may be getting the value for $fu or $tu if
python offers<br>
the api for getting/setting pseudo-variables -- these are
for sure in<br>
kemi exports to python.<br>
<br>
Of course, if anyone adds support for more parameters, then
it will be<br>
accepted inside kamailio repo.<br>
<br>
Cheers,<br>
Daniel<br>
<div class="HOEnZb">
<div class="h5"><br>
<br>
On 08/02/2017 09:47, gmele wrote:<br>
> Hello,<br>
><br>
> in our Kamailio, we are using python_exec to
execute script used to send<br>
> push notifications to Google or Apple.<br>
><br>
> Currenty, the method we call only accepts the
message as parameter. We then<br>
> extract from the message the Call Id, to URI and
from URI.<br>
><br>
> Here is the python method signature:<br>
><br>
> *def SendPushNotification(self, msg)*<br>
><br>
> To extract the toUri and fromUri (and remove the
sip:), we use python regex<br>
> :<br>
><br>
> *uriPattern=re.compile(".*<wbr>sips?:(.+@[^>;]+)")*<br>
><br>
> This is working well 99% of the time, except
sometimes (we don't know why)<br>
> where we get the error:<br>
><br>
> *logger_LM_ERR(): Exception occurred: Traceback
(most recent call last):<br>
> File "mypythonExample.py", line XXX, in
SendPushNotification<br>
> requestUri = self.ExtractURIFromHeader(msg.<wbr>getHeader("to"))<br>
> File "mypythonExample.py", line XXX, in
ExtractURIFromHeader<br>
> m= self.uriPattern.match(header);<br>
> TypeError: an integer is required*<br>
><br>
> We tried to analyze the cause of this error, but we
didn't find any problem<br>
> with the message itself (the message is complete,
with the *to *and *from<br>
> *correctly filled).<br>
><br>
> So, to avoid using the python regex, we have
decided to pass parameters to<br>
> the python script (callId, from and to URI):<br>
><br>
> *def SendPushRequest(self, msg, fromUri, toUri,
callid)*<br>
><br>
> But it seems python_exec doesn't support more than
2 parameters ($mb and<br>
> another one). Is this exact? If this is the case,
how can we pass several<br>
> parameters from kamailio.cfg?<br>
><br>
> Thx for your help.<br>
><br>
> Regards<br>
><br>
> Giovanni<br>
><br>
><br>
><br>
><br>
><br>
> --<br>
> View this message in context: <a
moz-do-not-send="true"
href="http://sip-router.1086192.n5.nabble.com/python-exec-and-parameters-tp155803.html"
rel="noreferrer" target="_blank">http://sip-router.1086192.n5.<wbr>nabble.com/python-exec-and-<wbr>parameters-tp155803.html</a><br>
> Sent from the Users mailing list archive at
Nabble.com.<br>
><br>
> ______________________________<wbr>_________________<br>
> SIP Express Router (SER) and Kamailio (OpenSER) -
sr-users mailing list<br>
> <a moz-do-not-send="true"
href="mailto:sr-users@lists.sip-router.org">sr-users@lists.sip-router.org</a><br>
> <a moz-do-not-send="true"
href="http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-users"
rel="noreferrer" target="_blank">http://lists.sip-router.org/<wbr>cgi-bin/mailman/listinfo/sr-<wbr>users</a><br>
<br>
</div>
</div>
<span class="HOEnZb"><font color="#888888">--<br>
Daniel-Constantin Mierla<br>
<a moz-do-not-send="true"
href="http://www.twitter.com/miconda" rel="noreferrer"
target="_blank">www.twitter.com/miconda</a> -- <a
moz-do-not-send="true"
href="http://www.linkedin.com/in/miconda"
rel="noreferrer" target="_blank">www.linkedin.com/in/miconda</a><br>
Kamailio Advanced Training - Mar 6-8 (Europe) and Mar
20-22 (USA) - <a moz-do-not-send="true"
href="http://www.asipto.com" rel="noreferrer"
target="_blank">www.asipto.com</a><br>
Kamailio World Conference - May 8-10, 2017 - <a
moz-do-not-send="true"
href="http://www.kamailioworld.com" rel="noreferrer"
target="_blank">www.kamailioworld.com</a><br>
</font></span>
<div class="HOEnZb">
<div class="h5"><br>
<br>
______________________________<wbr>_________________<br>
SIP Express Router (SER) and Kamailio (OpenSER) -
sr-users mailing list<br>
<a moz-do-not-send="true"
href="mailto:sr-users@lists.sip-router.org">sr-users@lists.sip-router.org</a><br>
<a moz-do-not-send="true"
href="http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-users"
rel="noreferrer" target="_blank">http://lists.sip-router.org/<wbr>cgi-bin/mailman/listinfo/sr-<wbr>users</a><br>
</div>
</div>
</blockquote>
</div>
<br>
</div>
</blockquote>
<br>
<pre class="moz-signature" cols="72">--
Daniel-Constantin Mierla
<a class="moz-txt-link-abbreviated" href="http://www.twitter.com/miconda">www.twitter.com/miconda</a> -- <a class="moz-txt-link-abbreviated" href="http://www.linkedin.com/in/miconda">www.linkedin.com/in/miconda</a>
Kamailio Advanced Training - Mar 6-8 (Europe) and Mar 20-22 (USA) - <a class="moz-txt-link-abbreviated" href="http://www.asipto.com">www.asipto.com</a>
Kamailio World Conference - May 8-10, 2017 - <a class="moz-txt-link-abbreviated" href="http://www.kamailioworld.com">www.kamailioworld.com</a></pre>
</body>
</html>