Hello Guys, 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: r = http.request('GET', ' https://www.massphoning.net/customer/inMassphoning/getInCampaignInfo?phone=' + caller) if r.status == 200: httpResult = json.loads(r.data.decode('utf-8')) Then print it like: print('Response Parsed: %s\n' % CampaignData) print('CamapignType: %s\n' % CampaignData['campaing_type']) and via the CLI works nicely. But when run on freeswitch dialplan print('Response Parsed: %s\n' % CampaignData) runs properly and prints on the log the data, but it fails on: print('CamapignType: %s\n' % CampaignData['campaing_type']) with: 2018-06-14 03:33:28.971179 [ERR] mod_python.c:164 Python Error by calling script "foo": <type 'exceptions.TypeError'> Message: in method 'consoleLog', argument 2 of type 'char *' Exception: None Traceback (most recent call last) File: "/opt/freeswitch/share/freeswitch/scripts/foo.py", line 16, in handler File: "/opt/freeswitch/share/freeswitch/scripts/foo.py", line 69, in getCampaignInfo Any ideas?? Thanks! Regards, David Villasmil email: david.villasmil.work@gmail.com phone: +34669448337 ᐧ
Hi David, If that happened to me I would run something like this: print('Test 1: %s\n' % CampaignData) print('Test 2: %s\n' % type(CampaignData['campaing_type'])) print('Test 3: %s\n' % str(CampaignData['campaing_type'])) Can you share the output? Joel. On Wed, Jun 13, 2018 at 6:50 PM, David Villasmil < david.villasmil.work@gmail.com> wrote:
Hello Guys,
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:
r = http.request('GET', 'https://www.massphoning.net/ customer/inMassphoning/getInCampaignInfo?phone=' + caller)
if r.status == 200: httpResult = json.loads(r.data.decode('utf-8'))
Then print it like: print('Response Parsed: %s\n' % CampaignData) print('CamapignType: %s\n' % CampaignData['campaing_type'])
and via the CLI works nicely.
But when run on freeswitch dialplan print('Response Parsed: %s\n' % CampaignData)
runs properly and prints on the log the data, but it fails on: print('CamapignType: %s\n' % CampaignData['campaing_type'])
with: 2018-06-14 03:33:28.971179 [ERR] mod_python.c:164 Python Error by calling script "foo": <type 'exceptions.TypeError'> Message: in method 'consoleLog', argument 2 of type 'char *' Exception: None
Traceback (most recent call last) File: "/opt/freeswitch/share/freeswitch/scripts/foo.py", line 16, in handler File: "/opt/freeswitch/share/freeswitch/scripts/foo.py", line 69, in getCampaignInfo
Any ideas??
Thanks! Regards,
David Villasmil email: david.villasmil.work@gmail.com phone: +34669448337 ᐧ
_________________________________________________________________________ Professional FreeSWITCH Services sales@freeswitch.com https://freeswitch.com
Official FreeSWITCH Sites https://freeswitch.com/oss https://freeswitch.org/confluence https://cluecon.com
FreeSWITCH-users mailing list FreeSWITCH-users@lists.freeswitch.org http://lists.freeswitch.org/mailman/listinfo/freeswitch-users UNSUBSCRIBE:http://lists.freeswitch.org/mailman/options/freeswitch-users https://freeswitch.com
Hey thanks for replying! Yep, i found that answer, but didn't update the question. Thanks! On Mon, Jun 18, 2018, 15:39 Joel Serrano <joel@textplus.com> wrote:
Hi David,
If that happened to me I would run something like this:
print('Test 1: %s\n' % CampaignData) print('Test 2: %s\n' % type(CampaignData['campaing_type'])) print('Test 3: %s\n' % str(CampaignData['campaing_type']))
Can you share the output? Joel.
On Wed, Jun 13, 2018 at 6:50 PM, David Villasmil < david.villasmil.work@gmail.com> wrote:
Hello Guys,
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:
r = http.request('GET', ' https://www.massphoning.net/customer/inMassphoning/getInCampaignInfo?phone= ' + caller)
if r.status == 200: httpResult = json.loads(r.data.decode('utf-8'))
Then print it like: print('Response Parsed: %s\n' % CampaignData) print('CamapignType: %s\n' % CampaignData['campaing_type'])
and via the CLI works nicely.
But when run on freeswitch dialplan print('Response Parsed: %s\n' % CampaignData)
runs properly and prints on the log the data, but it fails on: print('CamapignType: %s\n' % CampaignData['campaing_type'])
with: 2018-06-14 03:33:28.971179 [ERR] mod_python.c:164 Python Error by calling script "foo": <type 'exceptions.TypeError'> Message: in method 'consoleLog', argument 2 of type 'char *' Exception: None
Traceback (most recent call last) File: "/opt/freeswitch/share/freeswitch/scripts/foo.py", line 16, in handler File: "/opt/freeswitch/share/freeswitch/scripts/foo.py", line 69, in getCampaignInfo
Any ideas??
Thanks! Regards,
David Villasmil email: david.villasmil.work@gmail.com phone: +34669448337 ᐧ
_________________________________________________________________________ Professional FreeSWITCH Services sales@freeswitch.com https://freeswitch.com
Official FreeSWITCH Sites https://freeswitch.com/oss https://freeswitch.org/confluence https://cluecon.com
FreeSWITCH-users mailing list FreeSWITCH-users@lists.freeswitch.org http://lists.freeswitch.org/mailman/listinfo/freeswitch-users UNSUBSCRIBE:http://lists.freeswitch.org/mailman/options/freeswitch-users https://freeswitch.com
_________________________________________________________________________ Professional FreeSWITCH Services sales@freeswitch.com https://freeswitch.com
Official FreeSWITCH Sites https://freeswitch.com/oss https://freeswitch.org/confluence https://cluecon.com
FreeSWITCH-users mailing list FreeSWITCH-users@lists.freeswitch.org http://lists.freeswitch.org/mailman/listinfo/freeswitch-users UNSUBSCRIBE:http://lists.freeswitch.org/mailman/options/freeswitch-users https://freeswitch.com
participants (2)
-
David Villasmil
-
Joel Serrano