Catch Invalid Character errors
We should catch XML invalid character values so that we don't throw an unseemly traceback similar to this:
$ rmobj -r crawled_genethn
Are you sure you want to remove all the contents of the bucket 'crawled_genethn'? [yes/no] yes
Traceback (most recent call last):
File "/scratch0/pyenv/bin/rmobj", line 65, in <module>
for key in bucket.list():
File "/scratch0/pyenv/lib/python2.7/site-packages/boto/s3/bucketlistresultset.py", line 34, in bucket_lister
encoding_type=encoding_type)
File "/scratch0/pyenv/lib/python2.7/site-packages/boto/s3/bucket.py", line 473, in get_all_keys
'', headers, **params)
File "/scratch0/pyenv/lib/python2.7/site-packages/boto/s3/bucket.py", line 407, in _get_all
xml.sax.parseString(body, h)
File "/usr/lib64/python2.7/xml/sax/__init__.py", line 49, in parseString
parser.parse(inpsrc)
File "/usr/lib64/python2.7/xml/sax/expatreader.py", line 107, in parse
xmlreader.IncrementalParser.parse(self, source)
File "/usr/lib64/python2.7/xml/sax/xmlreader.py", line 123, in parse
self.feed(buffer)
File "/usr/lib64/python2.7/xml/sax/expatreader.py", line 214, in feed
self._err_handler.fatalError(exc)
File "/usr/lib64/python2.7/xml/sax/handler.py", line 38, in fatalError
raise exception
<type 'type'>: <unknown>:1:62008: reference to invalid character number
We should give a CRITICAL error in this case. It may also be good to shoot off a DEBUG level error with the failing XML.