beyondthebox/JSS-Resource-Tools

Failed to import double byte character

Opened this issue · 1 comments

Hi,
Failed to import csv file with double byte character(UTF-8) (attached sample file)
Failed it when I changed the sys.getdefaultencoding to utf-8 too.

$ jss_resource_tools --mode update --type mobiledevices --match serial_number jss-up_test1.csv
JSS Base URL: https://xxxxx.xxxxxx.com/
JSS Username: xxxx
JSS Password: xxxxx
JSS Resource Tools v1.15 by Beyond the Box Labs
Successfully authenticated to the JSS at https://xxxxx.xxxxxx.com.
Updating mobile devices from CSV:
[2] "general/name" changed from "test" to " テスト"
Traceback (most recent call last):
File "/usr/local/bin/jss_resource_tools", line 423, in
main()
File "/usr/local/lib/python2.7/site-packages/click/core.py", line 722, in call
return self.main(*args, **kwargs)
File "/usr/local/lib/python2.7/site-packages/click/core.py", line 697, in main
rv = self.invoke(ctx)
File "/usr/local/lib/python2.7/site-packages/click/core.py", line 895, in invoke
return ctx.invoke(self.callback, **ctx.params)
File "/usr/local/lib/python2.7/site-packages/click/core.py", line 535, in invoke
return callback(*args, **kwargs)
File "/usr/local/lib/python2.7/site-packages/click/decorators.py", line 17, in new_func
return f(get_current_context(), *args, **kwargs)
File "/usr/local/bin/jss_resource_tools", line 132, in main
update_from_csv(file)
File "/usr/local/lib/python2.7/site-packages/click/decorators.py", line 27, in new_func
return f(get_current_context().obj, *args, **kwargs)
File "/usr/local/bin/jss_resource_tools", line 278, in update_from_csv
put_jss_resource(resource_id, ET.tostring(matched_object))
File "/usr/local/Cellar/python/2.7.14_3/Frameworks/Python.framework/Versions/2.7/lib/python2.7/xml/etree/ElementTree.py", line 1126, in tostring
ElementTree(element).write(file, encoding, method=method)
File "/usr/local/Cellar/python/2.7.14_3/Frameworks/Python.framework/Versions/2.7/lib/python2.7/xml/etree/ElementTree.py", line 820, in write
serialize(write, self._root, encoding, qnames, namespaces)
File "/usr/local/Cellar/python/2.7.14_3/Frameworks/Python.framework/Versions/2.7/lib/python2.7/xml/etree/ElementTree.py", line 939, in _serialize_xml
_serialize_xml(write, e, encoding, qnames, None)
File "/usr/local/Cellar/python/2.7.14_3/Frameworks/Python.framework/Versions/2.7/lib/python2.7/xml/etree/ElementTree.py", line 939, in _serialize_xml
_serialize_xml(write, e, encoding, qnames, None)
File "/usr/local/Cellar/python/2.7.14_3/Frameworks/Python.framework/Versions/2.7/lib/python2.7/xml/etree/ElementTree.py", line 937, in _serialize_xml
write(_escape_cdata(text, encoding))
File "/usr/local/Cellar/python/2.7.14_3/Frameworks/Python.framework/Versions/2.7/lib/python2.7/xml/etree/ElementTree.py", line 1073, in _escape_cdata
return text.encode(encoding, "xmlcharrefreplace")
UnicodeDecodeError: 'ascii' codec can't decode byte 0xe3 in position 1: ordinal not in range(128)

jss-up_test1.txt

Same issue when exporting.