Hi,
is there any way to return values from a call to python_exec function orther than the default returned integer?
Following code generates this error: Oct 1 09:08:23 zskio /usr/sbin/kamailio[21789]: ERROR: app_python [python_support.c:38]: python_exec2: Unhandled exception in the Python code: Oct 1 09:08:23 zskio /usr/sbin/kamailio[21789]: ERROR: app_python [python_support.c:78]: #011RuntimeError: no such function
if (!python_exec("get_provider", $(var(clean_uri){s.prefixes}))) { xlog("L_ERR","Can not choose a provider for $rU\n"); sl_send_reply("503","Can not choose a provider for $rU"); exit; }
def get_provider(self, msg, param): # snipped code... result = self.util.get_provider(prefixes, position, mode) if result is not None: LM_ERR("mode: %s position: %d result: %s" % (mode, position, result)) # this raises error msg.call_function('rewritehost', result['provider']['ip']) return 1 return -1
I tried to use headers as transport but this simple code does not work:
Oct 1 09:45:31 zskio /usr/sbin/kamailio[22303]: ERROR: <script>: No header
if (!is_present_hf("X-Test-header")) { xlog("L_ERROR", "No header\n"); } else { xlog("L_INFO", "Header added\n"); }
def test_set_header(self, msg): msg.call_function('append_hf', 'X-Test-header: test\r\n') return 1
Thanks in advance.
Hello,
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.
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().
As a workaround for now, I suggest you put your token somehow in request uri (e.g., a parameter).
Cheers, Daniel
On 10/1/12 9:53 AM, Victor Seva wrote:
Hi,
is there any way to return values from a call to python_exec function orther than the default returned integer?
Following code generates this error: Oct 1 09:08:23 zskio /usr/sbin/kamailio[21789]: ERROR: app_python [python_support.c:38]: python_exec2: Unhandled exception in the Python code: Oct 1 09:08:23 zskio /usr/sbin/kamailio[21789]: ERROR: app_python [python_support.c:78]: #011RuntimeError: no such function
if (!python_exec("get_provider",
$(var(clean_uri){s.prefixes}))) { xlog("L_ERR","Can not choose a provider for $rU\n"); sl_send_reply("503","Can not choose a provider for $rU"); exit; }
def get_provider(self, msg, param): # snipped code... result = self.util.get_provider(prefixes, position, mode) if result is not None: LM_ERR("mode: %s position: %d result: %s" % (mode, position, result)) # this raises error msg.call_function('rewritehost', result['provider']['ip']) return 1 return -1
I tried to use headers as transport but this simple code does not work:
Oct 1 09:45:31 zskio /usr/sbin/kamailio[22303]: ERROR: <script>: No header
if (!is_present_hf("X-Test-header")) { xlog("L_ERROR", "No header\n"); } else { xlog("L_INFO", "Header added\n"); } def test_set_header(self, msg): msg.call_function('append_hf', 'X-Test-header: test\r\n') return 1
Thanks in advance.
SIP Express Router (SER) and Kamailio (OpenSER) - sr-users mailing list sr-users@lists.sip-router.org http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-users
Hello, I can contribute a python part, but currently I'm a very busy at the moment. I will write a patch to enable this ability (and many other features) as soon as possible.
2012/10/3 Daniel-Constantin Mierla miconda@gmail.com
Hello,
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.
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().
As a workaround for now, I suggest you put your token somehow in request uri (e.g., a parameter).
Cheers, Daniel
On 10/1/12 9:53 AM, Victor Seva wrote:
Hi,
is there any way to return values from a call to python_exec function orther than the default returned integer?
Following code generates this error: Oct 1 09:08:23 zskio /usr/sbin/kamailio[21789]: ERROR: app_python [python_support.c:38]: python_exec2: Unhandled exception in the Python code: Oct 1 09:08:23 zskio /usr/sbin/kamailio[21789]: ERROR: app_python [python_support.c:78]: #011RuntimeError: no such function
if (!python_exec("get_provider",
$(var(clean_uri){s.prefixes}))**) { xlog("L_ERR","Can not choose a provider for $rU\n"); sl_send_reply("503","Can not choose a provider for $rU"); exit; }
def get_provider(self, msg, param): # snipped code... result = self.util.get_provider(**prefixes, position, mode) if result is not None: LM_ERR("mode: %s position: %d result: %s" % (mode, position, result)) # this raises error msg.call_function('**rewritehost', result['provider']['ip']) return 1 return -1
I tried to use headers as transport but this simple code does not work:
Oct 1 09:45:31 zskio /usr/sbin/kamailio[22303]: ERROR: <script>: No header
if (!is_present_hf("X-Test-**header")) { xlog("L_ERROR", "No header\n"); } else { xlog("L_INFO", "Header added\n"); } def test_set_header(self, msg): msg.call_function('append_hf', 'X-Test-header: test\r\n') return 1
Thanks in advance.
______________________________**_________________ SIP Express Router (SER) and Kamailio (OpenSER) - sr-users mailing list sr-users@lists.sip-router.org http://lists.sip-router.org/**cgi-bin/mailman/listinfo/sr-**usershttp://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-users
-- Daniel-Constantin Mierla - http://www.asipto.com http://twitter.com/#!/miconda - http://www.linkedin.com/in/**micondahttp://www.linkedin.com/in/miconda Kamailio Advanced Training, Berlin, Nov 5-8, 2012 - http://asipto.com/u/kat Kamailio Advanced Training, Miami, USA, Nov 12-14, 2012 - http://asipto.com/u/katu
______________________________**_________________ SIP Express Router (SER) and Kamailio (OpenSER) - sr-users mailing list sr-users@lists.sip-router.org http://lists.sip-router.org/**cgi-bin/mailman/listinfo/sr-**usershttp://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-users
Hello,
On 10/3/12 6:38 PM, Konstantin M. wrote:
Hello, I can contribute a python part, but currently I'm a very busy at the moment. I will write a patch to enable this ability (and many other features) as soon as possible.
great, looking forward to your contributions.
Cheers, Daniel
2012/10/3 Daniel-Constantin Mierla <miconda@gmail.com mailto:miconda@gmail.com>
Hello, 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. 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(). As a workaround for now, I suggest you put your token somehow in request uri (e.g., a parameter). Cheers, Daniel On 10/1/12 9:53 AM, Victor Seva wrote: Hi, is there any way to return values from a call to python_exec function orther than the default returned integer? Following code generates this error: Oct 1 09:08:23 zskio /usr/sbin/kamailio[21789]: ERROR: app_python [python_support.c:38]: python_exec2: Unhandled exception in the Python code: Oct 1 09:08:23 zskio /usr/sbin/kamailio[21789]: ERROR: app_python [python_support.c:78]: #011RuntimeError: no such function if (!python_exec("get_provider", $(var(clean_uri){s.prefixes}))) { xlog("L_ERR","Can not choose a provider for $rU\n"); sl_send_reply("503","Can not choose a provider for $rU"); exit; } def get_provider(self, msg, param): # snipped code... result = self.util.get_provider(prefixes, position, mode) if result is not None: LM_ERR("mode: %s position: %d result: %s" % (mode, position, result)) # this raises error msg.call_function('rewritehost', result['provider']['ip']) return 1 return -1 I tried to use headers as transport but this simple code does not work: Oct 1 09:45:31 zskio /usr/sbin/kamailio[22303]: ERROR: <script>: No header if (!is_present_hf("X-Test-header")) { xlog("L_ERROR", "No header\n"); } else { xlog("L_INFO", "Header added\n"); } def test_set_header(self, msg): msg.call_function('append_hf', 'X-Test-header: test\r\n') return 1 Thanks in advance. _______________________________________________ SIP Express Router (SER) and Kamailio (OpenSER) - sr-users mailing list sr-users@lists.sip-router.org <mailto:sr-users@lists.sip-router.org> http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-users -- Daniel-Constantin Mierla - http://www.asipto.com http://twitter.com/#!/miconda <http://twitter.com/#%21/miconda> - http://www.linkedin.com/in/miconda Kamailio Advanced Training, Berlin, Nov 5-8, 2012 - http://asipto.com/u/kat Kamailio Advanced Training, Miami, USA, Nov 12-14, 2012 - http://asipto.com/u/katu _______________________________________________ SIP Express Router (SER) and Kamailio (OpenSER) - sr-users mailing list sr-users@lists.sip-router.org <mailto:sr-users@lists.sip-router.org> http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-users
SIP Express Router (SER) and Kamailio (OpenSER) - sr-users mailing list sr-users@lists.sip-router.org http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-users
I'm guessing that accessing pseudo-variables is still not possible in python? I haven't seen anything indicating so in any event. Could you confirm? Will probably switch to lua as well.
On Wed, Oct 3, 2012 at 4:38 PM, Konstantin M. evilzluk@gmail.com wrote:
Hello, I can contribute a python part, but currently I'm a very busy at the moment. I will write a patch to enable this ability (and many other features) as soon as possible.
2012/10/3 Daniel-Constantin Mierla miconda@gmail.com
Hello,
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.
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().
As a workaround for now, I suggest you put your token somehow in request uri (e.g., a parameter).
Cheers, Daniel
On 10/1/12 9:53 AM, Victor Seva wrote:
Hi,
is there any way to return values from a call to python_exec function orther than the default returned integer?
Following code generates this error: Oct 1 09:08:23 zskio /usr/sbin/kamailio[21789]: ERROR: app_python [python_support.c:38]: python_exec2: Unhandled exception in the Python code: Oct 1 09:08:23 zskio /usr/sbin/kamailio[21789]: ERROR: app_python [python_support.c:78]: #011RuntimeError: no such function
if (!python_exec("get_provider",
$(var(clean_uri){s.prefixes}))) { xlog("L_ERR","Can not choose a provider for $rU\n"); sl_send_reply("503","Can not choose a provider for $rU"); exit; }
def get_provider(self, msg, param): # snipped code... result = self.util.get_provider(prefixes, position, mode) if result is not None: LM_ERR("mode: %s position: %d result: %s" % (mode, position, result)) # this raises error msg.call_function('rewritehost', result['provider']['ip']) return 1 return -1
I tried to use headers as transport but this simple code does not work:
Oct 1 09:45:31 zskio /usr/sbin/kamailio[22303]: ERROR: <script>: No header
if (!is_present_hf("X-Test-header")) { xlog("L_ERROR", "No header\n"); } else { xlog("L_INFO", "Header added\n"); } def test_set_header(self, msg): msg.call_function('append_hf', 'X-Test-header: test\r\n') return 1
Thanks in advance.
SIP Express Router (SER) and Kamailio (OpenSER) - sr-users mailing list sr-users@lists.sip-router.org http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-users
-- Daniel-Constantin Mierla - http://www.asipto.com http://twitter.com/#!/miconda - http://www.linkedin.com/in/miconda Kamailio Advanced Training, Berlin, Nov 5-8, 2012 - http://asipto.com/u/kat Kamailio Advanced Training, Miami, USA, Nov 12-14, 2012 - http://asipto.com/u/katu
SIP Express Router (SER) and Kamailio (OpenSER) - sr-users mailing list sr-users@lists.sip-router.org http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-users
SIP Express Router (SER) and Kamailio (OpenSER) - sr-users mailing list sr-users@lists.sip-router.org http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-users
2012/10/3 Daniel-Constantin Mierla miconda@gmail.com:
Hello,
Hi Daniel,
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.
I had to change to lua scripting in order to use pvs.
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().
Oh. Thanks.
As a workaround for now, I suggest you put your token somehow in request uri (e.g., a parameter).
As I said before, I had to use lua scripts in order to be able to use pvs.
Thanks a lot for your reply.
Hello,
On 10/4/12 4:15 PM, Victor Seva wrote:
2012/10/3 Daniel-Constantin Mierla miconda@gmail.com:
Hello,
Hi Daniel,
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.
I had to change to lua scripting in order to use pvs.
good choice :-)
It would be good anyhow to update the app_python to work with pvs, but it's not me that can do it, fortunately someone else volunteered.
Cheers, Daniel
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().
Oh. Thanks.
As a workaround for now, I suggest you put your token somehow in request uri (e.g., a parameter).
As I said before, I had to use lua scripts in order to be able to use pvs.
Thanks a lot for your reply.