Apr-07-2020, 04:26 PM
I have a python script with the line
latin1_2 = unicode_esc.encode('cp1252')
and when I execute the script in a Windows Command prompt it executes just fine. But when python and the script is executed from A custom trigger in ServiceDesk Plus (https://www.manageengine.com/se/service-desk/) a web application (using tomcat) that allows you to run console commands in the background. the script generates this error
Could not convert data to an integer. traceback: Traceback (most recent call last): File "SDPToSDPRequestCreate\SDPToSDPRequestCreate.py", line 34, in <module> data = json.loads(string_escapeV2(jsonString)) File "C:\ManageEngine\ServiceDesk9335\integration\custom_scripts\SDPToSDPRequestCreate\myFunctions.py", line 119, in string_escapeV2 latin1_2 = unicode_esc.encode('cp1252') # 1:1 mapping back to bytes File "C:\Users\David\AppData\Local\Programs\Python\Python37\lib\encodings\cp1252.py", line 12, in encode return codecs.charmap_encode(input,errors,encoding_table) UnicodeEncodeError: 'charmap' codec can't encode character '\x96' in position 56: character maps to <undefined>
I don't understand what could be causing cp1252.py to behave differently. Does anyone know what could be causing this?
latin1_2 = unicode_esc.encode('cp1252')
and when I execute the script in a Windows Command prompt it executes just fine. But when python and the script is executed from A custom trigger in ServiceDesk Plus (https://www.manageengine.com/se/service-desk/) a web application (using tomcat) that allows you to run console commands in the background. the script generates this error
Could not convert data to an integer. traceback: Traceback (most recent call last): File "SDPToSDPRequestCreate\SDPToSDPRequestCreate.py", line 34, in <module> data = json.loads(string_escapeV2(jsonString)) File "C:\ManageEngine\ServiceDesk9335\integration\custom_scripts\SDPToSDPRequestCreate\myFunctions.py", line 119, in string_escapeV2 latin1_2 = unicode_esc.encode('cp1252') # 1:1 mapping back to bytes File "C:\Users\David\AppData\Local\Programs\Python\Python37\lib\encodings\cp1252.py", line 12, in encode return codecs.charmap_encode(input,errors,encoding_table) UnicodeEncodeError: 'charmap' codec can't encode character '\x96' in position 56: character maps to <undefined>
I don't understand what could be causing cp1252.py to behave differently. Does anyone know what could be causing this?