Hello,
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.
Cheers,
Daniel
Thanks Daniel,
KSR.pvx.evalx was exactly what I needed,
I was able to set the UAC request body to an existing PV without evaluating it in Python,KSR.pvx.evalx("$uac_req(body)", "$smsbody");
Thanks again,
Nick
On Mon, Apr 12, 2021 at 6:21 PM Daniel-Constantin Mierla <miconda@gmail.com> wrote:
Hello,
On 11.04.21 05:23, Nick wrote:
Hi all,
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,
For example the SMSops module has a PV called $smsbody 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,
In my Python file I have:smsbody = KSR.pv.get("$smsbody")
Which leads to:kamailio[226069]: UnicodeDecodeError: 'utf-8' codec can't decode byte 0x91 in position 7: invalid start byte
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
Is there a way to set a PV in Kemi without actually interpreting it?
Is there a way to run an arbitrary line of native Kamailio config from Kemi like KSR.x.modf?
In reality all I need to do is:$uac_req(body) = $smsbody;
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.
this seems to be some limitation coming from embedding Python with string parameters for functions.
Can you try:
KSR.pvx.evalx("$uac_req(body)", "$$(smsbody)");
Note the $$ in second parameter, because it is the same as:
* https://kamailio.org/docs/modules/devel/modules/pv.html#pv.f.pv_evalx
Cheers,
Daniel
-- Daniel-Constantin Mierla -- www.asipto.com www.twitter.com/miconda -- www.linkedin.com/in/miconda Kamailio Advanced Training - Online May 17-20, 2021 (Europe Timezone) - June 7-10, 2021 (America Timezone) * https://www.asipto.com/sw/kamailio-advanced-training-online/
-- Daniel-Constantin Mierla -- www.asipto.com www.twitter.com/miconda -- www.linkedin.com/in/miconda Kamailio Advanced Training - Online May 17-20, 2021 (Europe Timezone) - June 7-10, 2021 (America Timezone) * https://www.asipto.com/sw/kamailio-advanced-training-online/