Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ascii error with oe_generate_legend.py #47

Closed
srussking opened this issue Jan 14, 2016 · 1 comment
Closed

Ascii error with oe_generate_legend.py #47

srussking opened this issue Jan 14, 2016 · 1 comment

Comments

@srussking
Copy link

This seems likely to be related to my version of python (2.7), but I am getting the following error when processing xml.

Reading color map: http://map1b.vis.earthdata.nasa.gov/colormaps/AIRS_Dust_Score.xml
Accessing URL http://map1b.vis.earthdata.nasa.gov/colormaps/AIRS_Dust_Score.xml
Traceback (most recent call last):
File "/Users/russ/Rails/airs_rails/lib/assets/oe_generate_legend.py", line 932, in
colormap_elements = parse_colormaps(colormap_location, options.verbose)
File "/Users/russ/Rails/airs_rails/lib/assets/oe_generate_legend.py", line 202, in parse_colormaps
tree=ET.fromstring(dom.toxml())
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/xml/etree/ElementTree.py", line 1300, in XML
parser.feed(text)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/xml/etree/ElementTree.py", line 1640, in feed
self._parser.Parse(data, 0)
UnicodeEncodeError: 'ascii' codec can't encode character u'\u2013' in position 217: ordinal not in range(128)

This is happening on files loaded via the local store, or via url.

@srussking
Copy link
Author

Fixed by adding encoding to a couple of places. Fix can be seen here

https://github.com/srussking/onearth/blob/master/src/generate_legend/oe_generate_legend.py

line 97

    def __str__(self):
        return self.__repr__().encode('utf-8')

line 201

    tree=ET.fromstring(dom.toxml(encoding='utf-8'))

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant