<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
</head>
<body>
<p>Hello,</p>
<div class="moz-cite-prefix">On 11.04.21 05:23, Nick wrote:<br>
</div>
<blockquote type="cite"
cite="mid:CALxx1oGggWwO+dGc9wysC_3B4JU0obnYLeeFrx0OUCDRG+6XHg@mail.gmail.com">
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<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 class="moz-txt-link-freetext" href="https://kamailio.org/docs/modules/devel/modules/pv.html#pv.f.pv_evalx">https://kamailio.org/docs/modules/devel/modules/pv.html#pv.f.pv_evalx</a></p>
<p>Cheers,<br>
Daniel<br>
</p>
<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>