<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
</head>
<body>
<p>Hello,</p>
<p>using KSR.pvx.evalx("$uac_req(body)", "$smsbody") works fine as
long as there is no '$...' inside $smsbody, because the second
parameter is evaluated twice for variables. That's the reason I
gave the example with $$(smsbody), so first time $$ is evaluate to
$, resulting in $(smsbody), which is then evaluated again.</p>
<p>Cheers,<br>
Daniel<br>
</p>
<div class="moz-cite-prefix">On 12.04.21 23:46, Nick wrote:<br>
</div>
<blockquote type="cite"
cite="mid:CALxx1oGTc4jH78HjCRDTfG_kY7asw7y4=AAQEgCdAF=WShE42A@mail.gmail.com">
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<div dir="ltr">Thanks Daniel,
<div><br>
</div>
<div>KSR.pvx.evalx was exactly what IÂ needed,<br>
</div>
<div><br>
</div>
<div>I was able to set the UAC request body to an existing PV
without evaluating it in Python,</div>
<div><font face="monospace">KSR.pvx.evalx("$uac_req(body)",
"$smsbody");</font><br>
</div>
<div><br>
</div>
<div>Thanks again,<br>
Nick</div>
</div>
<br>
<div class="gmail_quote">
<div dir="ltr" class="gmail_attr">On Mon, Apr 12, 2021 at 6:21
PM Daniel-Constantin Mierla <<a
href="mailto:miconda@gmail.com" target="_blank"
moz-do-not-send="true">miconda@gmail.com</a>> wrote:<br>
</div>
<blockquote class="gmail_quote" style="margin:0px 0px 0px
0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
<div>
<p>Hello,</p>
<div>On 11.04.21 05:23, Nick wrote:<br>
</div>
<blockquote type="cite">
<div dir="ltr">Hi all,
<div><br>
<div>I'm trying in KEMI & Python to set a Pseudo
Variable to the value of another PV (simple enough)
but the value of the PV is not a string or an
integer,</div>
<div><br>
</div>
<div>For example the <a
href="https://github.com/kamailio/kamailio/tree/master/src/modules/smsops"
target="_blank" moz-do-not-send="true">SMSops</a>
module has a PV called <font face="monospace">$smsbody</font>
which I need to set the message body to equal in
UAC, but I'm not able to load it to set it as the
message body,</div>
<div><br>
</div>
<div>In my Python file I have:</div>
<div><font face="monospace">smsbody =
KSR.pv.get("$smsbody")</font></div>
<div><br>
</div>
<div>Which leads to:</div>
<div><font face="monospace">kamailio[226069]:
UnicodeDecodeError: 'utf-8' codec can't decode
byte 0x91 in position 7: invalid start byte<br>
kamailio[226069]: Â 2(226069) DEBUG: app_python3
[apy_kemi.c:112]: sr_kemi_config_engine_python():
execution of route type 1 with no name returned -1</font><br>
<br>
</div>
<div><b>Is there a way to set a PV in Kemi without
actually interpreting it?</b></div>
<div><b><br>
</b></div>
<div><b>Is there a way to run an arbitrary line of
native Kamailio config from Kemi like KSR.x.modf? </b></div>
<div><br>
</div>
<div>In reality all I need to do is:</div>
<div><font face="monospace">$uac_req(body) =
$smsbody;Â </font></div>
<div><br>
</div>
<div>Would work fine in the native config, but the
equivalent in Kemi tries to parse the contents and
fails, so can't set the body.<br>
</div>
</div>
</div>
</blockquote>
<p>this seems to be some limitation coming from embedding
Python with string parameters for functions.</p>
<p>Can you try:<br>
</p>
<p>KSR.pvx.evalx("$uac_req(body)", "$$(smsbody)");</p>
<p>Note the $$ in second parameter, because it is the same
as:</p>
<p>Â * <a
href="https://kamailio.org/docs/modules/devel/modules/pv.html#pv.f.pv_evalx"
target="_blank" moz-do-not-send="true">https://kamailio.org/docs/modules/devel/modules/pv.html#pv.f.pv_evalx</a></p>
<p>Cheers,<br>
Daniel<br>
</p>
<pre cols="72">--
Daniel-Constantin Mierla -- <a href="http://www.asipto.com" target="_blank" moz-do-not-send="true">www.asipto.com</a>
<a href="http://www.twitter.com/miconda" target="_blank" moz-do-not-send="true">www.twitter.com/miconda</a> -- <a href="http://www.linkedin.com/in/miconda" target="_blank" moz-do-not-send="true">www.linkedin.com/in/miconda</a>
Kamailio Advanced Training - Online
May 17-20, 2021 (Europe Timezone) - June 7-10, 2021 (America Timezone)
* <a href="https://www.asipto.com/sw/kamailio-advanced-training-online/" target="_blank" moz-do-not-send="true">https://www.asipto.com/sw/kamailio-advanced-training-online/</a></pre>
</div>
</blockquote>
</div>
</blockquote>
<pre class="moz-signature" cols="72">--
Daniel-Constantin Mierla -- <a class="moz-txt-link-abbreviated" href="http://www.asipto.com">www.asipto.com</a>
<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 - Online
May 17-20, 2021 (Europe Timezone) - June 7-10, 2021 (America Timezone)
* <a class="moz-txt-link-freetext" href="https://www.asipto.com/sw/kamailio-advanced-training-online/">https://www.asipto.com/sw/kamailio-advanced-training-online/</a></pre>
</body>
</html>