Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Mute
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I'm trying to run a simple volume-get-iter against a number of our clusters, and then using xmltodict I want to convert the XML to a dictionary so that I can simply dump it in json format. It's working fine for all but one of our cdot clusters, but I think it's breaking on a cluster where there may be an odd character in a volume name.
File "./y.py", line 39, in <module>
xml_parser = out.sprintf()
File "/local/mnt/netappsplunk/NaElement.py", line 236, in sprintf
s = s+c.sprintf(indent + "\t")
File "/local/mnt/netappsplunk/NaElement.py", line 236, in sprintf
s = s+c.sprintf(indent + "\t")
File "/local/mnt/netappsplunk/NaElement.py", line 236, in sprintf
s = s+c.sprintf(indent + "\t")
File "/local/mnt/netappsplunk/NaElement.py", line 236, in sprintf
s = s+c.sprintf(indent + "\t")
File "/local/mnt/netappsplunk/NaElement.py", line 239, in sprintf
s = s + str(self.element['content'])
UnicodeEncodeError: 'ascii' codec can't encode character u'\xa0' in position 30: ordinal not in range(128)
I tried to just do a replace, but that fails:
out = (s.invoke_elem(volume_list)).replace('\\xa0', ' ')
AttributeError: NaElement instance has no attribute 'replace'
Is there a way to make this work?
Solved! See The Solution
1 ACCEPTED SOLUTION
JonathanSneep has accepted the solution
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Solved, by adding the following to NaElement.py
I'm open to other ideas or educational comments though 🙂
sys.setdefaultencoding('utf-8')
2 REPLIES 2
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I believe now that I should modify the sprintf function in NaElement, but i'm not sure exactly how.
JonathanSneep has accepted the solution
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Solved, by adding the following to NaElement.py
I'm open to other ideas or educational comments though 🙂
sys.setdefaultencoding('utf-8')
