<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">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">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">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">www.asipto.com</a>
<a href="http://www.twitter.com/miconda" target="_blank">www.twitter.com/miconda</a> -- <a href="http://www.linkedin.com/in/miconda" target="_blank">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">https://www.asipto.com/sw/kamailio-advanced-training-online/</a></pre>
</div>
</blockquote></div>