<html>
  <head>
    <meta content="text/html; charset=ISO-8859-1"
      http-equiv="Content-Type">
  </head>
  <body text="#000000" bgcolor="#FFFFFF">
    Hello,<br>
    <br>
    <div class="moz-cite-prefix">On 10/3/12 6:38 PM, Konstantin M.
      wrote:<br>
    </div>
    <blockquote
cite="mid:CAEYtTzfL_fEzhTSAPNnGuHDhbFNkEendjb3Her8hGaOPuPeGkQ@mail.gmail.com"
      type="cite">Hello,<br>
      I can contribute a python part, but currently I'm a very busy at
      the moment. <br>
      I will write a patch to enable this ability (and many other
      features) as soon as possible.<br>
    </blockquote>
    great, looking forward to your contributions.<br>
    <br>
    Cheers,<br>
    Daniel<br>
    <br>
    <blockquote
cite="mid:CAEYtTzfL_fEzhTSAPNnGuHDhbFNkEendjb3Her8hGaOPuPeGkQ@mail.gmail.com"
      type="cite"><br>
      <div class="gmail_quote">2012/10/3 Daniel-Constantin Mierla <span
          dir="ltr">&lt;<a moz-do-not-send="true"
            href="mailto:miconda@gmail.com" target="_blank">miconda@gmail.com</a>&gt;</span><br>
        <blockquote class="gmail_quote" style="margin:0pt 0pt 0pt
          0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">Hello,<br>
          <br>
          the best would be to enhance the module to be able to get/set
          pseudo-variables. I am not a python guy at all, so I cannot
          help much, however I can assist with the C side in kamailio if
          someone starts development and has questions about PVs.<br>
          <br>
          Calling config functions with parameters from embedded
          interpreters exposes the risk of memory leaks, so it is better
          to avoid it. Anyhow, added headers are not visible immediately
          (even when done form config file), unless you call
          msg_apply_changes().<br>
          <br>
          As a workaround for now, I suggest you put your token somehow
          in request uri (e.g., a parameter).<br>
          <br>
          Cheers,<br>
          Daniel
          <div class="HOEnZb">
            <div class="h5"><br>
              <br>
              On 10/1/12 9:53 AM, Victor Seva wrote:<br>
              <blockquote class="gmail_quote" style="margin:0pt 0pt 0pt
                0.8ex;border-left:1px solid
                rgb(204,204,204);padding-left:1ex">
                Hi,<br>
                <br>
                is there any way to return values from a call to
                python_exec function<br>
                orther than the default returned integer?<br>
                <br>
                Following code generates this error:<br>
                Oct &nbsp;1 09:08:23 zskio /usr/sbin/kamailio[21789]: ERROR:
                app_python<br>
                [python_support.c:38]: python_exec2: Unhandled exception
                in the Python<br>
                code:<br>
                Oct &nbsp;1 09:08:23 zskio /usr/sbin/kamailio[21789]: ERROR:
                app_python<br>
                [python_support.c:78]: #011RuntimeError: no such
                function<br>
                <br>
                &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;if (!python_exec("get_provider",<br>
                $(var(clean_uri){s.prefixes}))) {<br>
                &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;xlog("L_ERR","Can not choose a
                provider for $rU\n");<br>
                &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;sl_send_reply("503","Can not
                choose a provider<br>
                for $rU");<br>
                &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;exit;<br>
                &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;}<br>
                <br>
                <br>
                def get_provider(self, msg, param):<br>
                &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;# snipped code...<br>
                &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;result = self.util.get_provider(prefixes,
                position, mode)<br>
                &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;if result is not None:<br>
                &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;LM_ERR("mode: %s position: %d result: %s" %
                (mode,<br>
                position, result))<br>
                &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;# this raises error<br>
                &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;msg.call_function('rewritehost',
                result['provider']['ip'])<br>
                &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;return 1<br>
                &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;return -1<br>
                <br>
                I tried to use headers as transport but this simple code
                does not work:<br>
                <br>
                Oct &nbsp;1 09:45:31 zskio /usr/sbin/kamailio[22303]: ERROR:
                &lt;script&gt;: No header<br>
                <br>
                &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;if (!is_present_hf("X-Test-header")) {<br>
                &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;xlog("L_ERROR", "No header\n");<br>
                &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;}<br>
                &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;else {<br>
                &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;xlog("L_INFO", "Header
                added\n");<br>
                &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;}<br>
                <br>
                &nbsp; &nbsp; &nbsp;def test_set_header(self, msg):<br>
                &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;msg.call_function('append_hf', 'X-Test-header:
                test\r\n')<br>
                &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;return 1<br>
                <br>
                Thanks in advance.<br>
                <br>
                _______________________________________________<br>
                SIP Express Router (SER) and Kamailio (OpenSER) -
                sr-users mailing list<br>
                <a moz-do-not-send="true"
                  href="mailto:sr-users@lists.sip-router.org"
                  target="_blank">sr-users@lists.sip-router.org</a><br>
                <a moz-do-not-send="true"
                  href="http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-users"
                  target="_blank">http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-users</a><br>
              </blockquote>
              <br>
            </div>
          </div>
          <span class="HOEnZb"><font color="#888888">
              -- <br>
              Daniel-Constantin Mierla - <a moz-do-not-send="true"
                href="http://www.asipto.com" target="_blank">http://www.asipto.com</a><br>
              <a moz-do-not-send="true"
                href="http://twitter.com/#%21/miconda" target="_blank">http://twitter.com/#!/miconda</a>
              - <a moz-do-not-send="true"
                href="http://www.linkedin.com/in/miconda"
                target="_blank">http://www.linkedin.com/in/miconda</a><br>
              Kamailio Advanced Training, Berlin, Nov 5-8, 2012 - <a
                moz-do-not-send="true" href="http://asipto.com/u/kat"
                target="_blank">http://asipto.com/u/kat</a><br>
              Kamailio Advanced Training, Miami, USA, Nov 12-14, 2012 -
              <a moz-do-not-send="true" href="http://asipto.com/u/katu"
                target="_blank">http://asipto.com/u/katu</a></font></span>
          <div class="HOEnZb">
            <div class="h5"><br>
              <br>
              <br>
              _______________________________________________<br>
              SIP Express Router (SER) and Kamailio (OpenSER) - sr-users
              mailing list<br>
              <a moz-do-not-send="true"
                href="mailto:sr-users@lists.sip-router.org"
                target="_blank">sr-users@lists.sip-router.org</a><br>
              <a moz-do-not-send="true"
                href="http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-users"
                target="_blank">http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-users</a><br>
            </div>
          </div>
        </blockquote>
      </div>
      <br>
      <br>
      <fieldset class="mimeAttachmentHeader"></fieldset>
      <br>
      <pre wrap="">_______________________________________________
SIP Express Router (SER) and Kamailio (OpenSER) - sr-users mailing list
<a class="moz-txt-link-abbreviated" href="mailto:sr-users@lists.sip-router.org">sr-users@lists.sip-router.org</a>
<a class="moz-txt-link-freetext" href="http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-users">http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-users</a>
</pre>
    </blockquote>
    <br>
    <pre class="moz-signature" cols="72">-- 
Daniel-Constantin Mierla - <a class="moz-txt-link-freetext" href="http://www.asipto.com">http://www.asipto.com</a>
<a class="moz-txt-link-freetext" href="http://twitter.com/#!/miconda">http://twitter.com/#!/miconda</a> - <a class="moz-txt-link-freetext" href="http://www.linkedin.com/in/miconda">http://www.linkedin.com/in/miconda</a>
Kamailio Advanced Training, Berlin, Nov 5-8, 2012 - <a class="moz-txt-link-freetext" href="http://asipto.com/u/kat">http://asipto.com/u/kat</a>
Kamailio Advanced Training, Miami, USA, Nov 12-14, 2012 - <a class="moz-txt-link-freetext" href="http://asipto.com/u/katu">http://asipto.com/u/katu</a></pre>
  </body>
</html>