boto/boto — Issue #546: Autoscale LaunchConfiguration CreateTime cannot have whitespace in the XML format
Author: buzztroll
Created: 2012-02-03 06:26:44+00:00
State: open

If the following is sent from the service:

2012-02-03T06:22:23.556530Z

It results in this boto error:
Traceback (most recent call last):
File "/home/bresnaha/pycharm-1.5.4/helpers/pydev/pydevd.py", line 1203, in
debugger.run(setup['file'], None, None)
File "/home/bresnaha/pycharm-1.5.4/helpers/pydev/pydevd.py", line 959, in run
execfile(file, globals, locals) #execute the script
File "/home/bresnaha/Dev/routeswsgitest/client_test.py", line 42, in
x = con.get_all_launch_configurations()
File "/usr/lib/python2.7/dist-packages/boto/ec2/autoscale/__init__.py", line 294, in get_all_launch_configurations
[('member', LaunchConfiguration)])
File "/usr/lib/python2.7/dist-packages/boto/connection.py", line 675, in get_list
xml.sax.parseString(body, h)
File "/usr/lib/python2.7/xml/sax/__init__.py", line 49, in parseString
parser.parse(inpsrc)
File "/usr/lib/python2.7/xml/sax/expatreader.py", line 107, in parse
xmlreader.IncrementalParser.parse(self, source)
File "/usr/lib/python2.7/xml/sax/xmlreader.py", line 123, in parse
self.feed(buffer)
File "/usr/lib/python2.7/xml/sax/expatreader.py", line 207, in feed
self._parser.Parse(data, isFinal)
File "/usr/lib/python2.7/xml/sax/expatreader.py", line 304, in end_element
self._cont_handler.endElement(name)
File "/usr/lib/python2.7/dist-packages/boto/handler.py", line 38, in endElement
self.nodes[-1][1].endElement(name, self.current_text, self.connection)
File "/usr/lib/python2.7/dist-packages/boto/ec2/autoscale/launchconfig.py", line 169, in endElement
self.created_time = datetime.strptime(value, '%Y-%m-%dT%H:%M:%S.%fZ')
File "/usr/lib/python2.7/_strptime.py", line 325, in _strptime
(data_string, format))
ValueError: time data '\n\t\t\t\t\t2012-02-03T06:22:23.556530Z\n\t\t\t\t' does not match format '%Y-%m-%dT%H:%M:%S.%fZ'

This patch should fix it:

--- boto-2.1.1/boto/ec2/autoscale/launchconfig.py	2011-10-27 02:59:54.000000000 -1000
+++ boto-2.1.1-buzz/boto/ec2/autoscale/launchconfig.py	2012-02-02 19:58:30.618439341 -1000
@@ -166,6 +166,7 @@
elif name == 'ImageId':
self.image_id = value
elif name == 'CreatedTime':
+ value = value.strip()
try:
self.created_time = datetime.strptime(value, '%Y-%m-%dT%H:%M:%S.%fZ')
except ValueError: