peterknife / boto

Automatically exported from code.google.com/p/boto
0 stars 0 forks source link

get_all_launch_configurations() fails with a launch configuration created on the second #551

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?

1. Somehow manage to create a launch configuration at exactly a whole second 
(in other words, e.g. 12:45:03, not 12:45:03.005).  When creating a launch 
config, you have a 1/1000 chance of succeeding each time; 

2. Call get_all_launch_configurations()

3. Profit!

What is the expected output? What do you see instead?

Expected output is a list of launch configs.  What we get instead:

Traceback (most recent call last):
  File "./UsageGetter.py", line 212, in <module>
    ug.log_usage()
  File "./UsageGetter.py", line 103, in log_usage
    udict = self.usage()
  File "./UsageGetter.py", line 89, in usage
    (count, size) = self._get_resource(uncorrected_resourcename, conn)
  File "./UsageGetter.py", line 180, in _get_resource
    resources = method(next_token = next_token)
  File "/usr/lib/python2.7/site-packages/boto/ec2/autoscale/__init__.py", line 294, in get_all_launch_configurations
    [('member', LaunchConfiguration)])
  File "/usr/lib/python2.7/site-packages/boto/connection.py", line 675, in get_list
    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 207, in feed
    self._parser.Parse(data, isFinal)
  File "/usr/lib64/python2.7/xml/sax/expatreader.py", line 304, in end_element
    self._cont_handler.endElement(name)
  File "/usr/lib/python2.7/site-packages/boto/handler.py", line 38, in endElement
    self.nodes[-1][1].endElement(name, self.current_text, self.connection)
  File "/usr/lib/python2.7/site-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/lib64/python2.7/_strptime.py", line 325, in _strptime
    (data_string, format))
ValueError: time data '2011-08-24T17:17:01Z' does not match format 
'%Y-%m-%dT%H:%M:%S.%fZ'

What version of the product are you using? On what operating system?

Boto 2.0 on RHEL 5.5

Please provide any additional information below.

Changing ec2/autoscale/launchconfig.py

line 170 from:

                self.created_time = datetime.strptime(value, '%Y-%m-%dT%H:%M:%S.%fZ')

to

            if value.find(".") != -1:  
                self.created_time = datetime.strptime(value, '%Y-%m-%dT%H:%M:%S.%fZ')
            else:   
                self.created_time = datetime.strptime(value, '%Y-%m-%dT%H:%M:%SZ')

fixes the problem

Original issue reported on code.google.com by royrapop...@gmail.com on 26 Aug 2011 at 3:49

GoogleCodeExporter commented 9 years ago
See https://github.com/boto/boto/issues/314

Original comment by Mitch.Ga...@gmail.com on 26 Aug 2011 at 6:47