<div dir="ltr">Hello Guys, <div><br></div><div>I'm writing a script in python which when run via cli works properly. I get some dta via http (urllib3) and parse it like:</div><div><br></div><div><div style="color:rgb(212,212,212);background-color:rgb(30,30,30);font-family:Menlo,Monaco,"Courier New",monospace,"Apple Color Emoji";font-weight:normal;font-size:12px;line-height:18px;white-space:pre"><div><span style="color:rgb(212,212,212)">    r </span><span style="color:rgb(212,212,212)">=</span><span style="color:rgb(212,212,212)"> http.request(</span><span style="color:rgb(206,145,120)">'GET'</span><span style="color:rgb(212,212,212)">, </span><span style="color:rgb(206,145,120)">'<a href="https://www.massphoning.net/customer/inMassphoning/getInCampaignInfo?phone=">https://www.massphoning.net/customer/inMassphoning/getInCampaignInfo?phone=</a>'</span><span style="color:rgb(212,212,212)"> </span><span style="color:rgb(212,212,212)">+</span><span style="color:rgb(212,212,212)"> caller)</span></div><br><div><span style="color:rgb(212,212,212)">    </span><span style="color:rgb(197,134,192)">if</span><span style="color:rgb(212,212,212)"> r.status </span><span style="color:rgb(212,212,212)">==</span><span style="color:rgb(212,212,212)"> </span><span style="color:rgb(181,206,168)">200</span><span style="color:rgb(212,212,212)">:</span></div><div><span style="color:rgb(212,212,212)">        httpResult </span><span style="color:rgb(212,212,212)">=</span><span style="color:rgb(212,212,212)"> json.loads(r.data.decode(</span><span style="color:rgb(206,145,120)">'utf-8'</span><span style="color:rgb(212,212,212)">))</span></div></div><br></div><div>Then print it like:</div><div><div style="color:rgb(212,212,212);background-color:rgb(30,30,30);font-family:Menlo,Monaco,"Courier New",monospace,"Apple Color Emoji";font-weight:normal;font-size:12px;line-height:18px;white-space:pre"><div><span style="color:rgb(212,212,212)">        </span><span style="color:rgb(220,220,170)">print</span><span style="color:rgb(212,212,212)">(</span><span style="color:rgb(206,145,120)">'Response Parsed: </span><span style="color:rgb(86,156,214)">%s</span><span style="color:rgb(215,186,125)">\n</span><span style="color:rgb(206,145,120)">'</span><span style="color:rgb(212,212,212)"> </span><span style="color:rgb(212,212,212)">%</span><span style="color:rgb(212,212,212)"> CampaignData)</span></div><div><span style="color:rgb(212,212,212)">        </span><span style="color:rgb(220,220,170)">print</span><span style="color:rgb(212,212,212)">(</span><span style="color:rgb(206,145,120)">'CamapignType: </span><span style="color:rgb(86,156,214)">%s</span><span style="color:rgb(215,186,125)">\n</span><span style="color:rgb(206,145,120)">'</span><span style="color:rgb(212,212,212)"> </span><span style="color:rgb(212,212,212)">%</span><span style="color:rgb(212,212,212)"> CampaignData[</span><span style="color:rgb(206,145,120)">'campaing_type'</span><span style="color:rgb(212,212,212)">])</span></div></div> </div><div>and via the CLI works nicely.</div><div><br></div><div>But when run on freeswitch dialplan </div><div><div style="color:rgb(212,212,212);background-color:rgb(30,30,30);font-family:Menlo,Monaco,"Courier New",monospace,"Apple Color Emoji";font-weight:normal;font-size:12px;line-height:18px;white-space:pre"><div><span style="color:rgb(212,212,212)">        </span><span style="color:rgb(220,220,170)">print</span><span style="color:rgb(212,212,212)">(</span><span style="color:rgb(206,145,120)">'Response Parsed: </span><span style="color:rgb(86,156,214)">%s</span><span style="color:rgb(215,186,125)">\n</span><span style="color:rgb(206,145,120)">'</span><span style="color:rgb(212,212,212)"> </span><span style="color:rgb(212,212,212)">%</span><span style="color:rgb(212,212,212)"> CampaignData)</span></div></div><div><br></div><div>runs properly and prints on the log the data, but <span style="background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial;float:none;display:inline">it fails on:</span></div><div style="color:rgb(212,212,212);background-color:rgb(30,30,30);font-family:Menlo,Monaco,"Courier New",monospace,"Apple Color Emoji";font-weight:normal;font-size:12px;line-height:18px;white-space:pre"><div>        <span style="color:rgb(220,220,170)">print</span>(<span style="color:rgb(206,145,120)">'CamapignType: </span><span style="color:rgb(86,156,214)">%s</span><span style="color:rgb(215,186,125)">\n</span><span style="color:rgb(206,145,120)">'</span> % CampaignData[<span style="color:rgb(206,145,120)">'campaing_type'</span>])<br></div></div><div><br></div><div>with:</div><div><div><font face="monospace, monospace">2018-06-14 03:33:28.971179 [ERR] mod_python.c:164 Python Error by calling script "foo": <type 'exceptions.TypeError'></font></div><div><font face="monospace, monospace">Message: in method 'consoleLog', argument 2 of type 'char *'</font></div><div><font face="monospace, monospace">Exception: None</font></div><div><font face="monospace, monospace"><br></font></div><div><font face="monospace, monospace">Traceback (most recent call last)</font></div><div><font face="monospace, monospace"><span style="white-space:pre">   </span>File: "/opt/freeswitch/share/freeswitch/scripts/foo.py", line 16, in handler</font></div><div><font face="monospace, monospace"><span style="white-space:pre"> </span>File: "/opt/freeswitch/share/freeswitch/scripts/foo.py", line 69, in getCampaignInfo</font></div></div><div><br></div><div>Any ideas??</div><div><br></div><div><br></div><div>Thanks!<br clear="all"><div><div dir="ltr" class="gmail_signature"><div dir="ltr"><div>Regards,</div><div><br></div>David Villasmil<div>email: <a href="mailto:david.villasmil.work@gmail.com" target="_blank">david.villasmil.work@gmail.com</a></div><div>phone: +34669448337</div></div></div></div></div></div></div><div hspace="streak-pt-mark" style="max-height:1px"><img alt="" style="width:0px;max-height:0px;overflow:hidden" src="https://mailfoogae.appspot.com/t?sender=aZGF2aWQudmlsbGFzbWlsLndvcmtAZ21haWwuY29t&type=zerocontent&guid=9abe7077-8b82-4a0b-805f-202ca9a7efb8"><font color="#ffffff" size="1">ᐧ</font></div>