[SR-Users] KEMI - Set message body to Bytes / Prevent parsing PV?

Nick nick at nickvsnetworking.com
Mon Apr 12 23:46:14 CEST 2021


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 at 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
> <https://github.com/kamailio/kamailio/tree/master/src/modules/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.comwww.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/
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.kamailio.org/pipermail/sr-users/attachments/20210413/80191d9b/attachment.htm>


More information about the sr-users mailing list