diff options
author | Mitch Garnaat <mitch@garnaat.com> | 2012-02-03 05:50:04 -0800 |
---|---|---|
committer | Mitch Garnaat <mitch@garnaat.com> | 2012-02-03 05:50:04 -0800 |
commit | 8c1f606b74b0a734bc00398dcf519f9af6387e59 (patch) | |
tree | 4cd472314847f6bd7d6419c35ca81ce53db8f7ae /boto/ec2/autoscale/launchconfig.py | |
parent | a30a45f41f14fbccf12c2f655f9795167acec459 (diff) | |
download | boto-8c1f606b74b0a734bc00398dcf519f9af6387e59.tar.gz |
Make parsing of CreatedTime more robust by using boto.utils.parse_ts. Also, strip any whitespace from ts prior to attempting conversion to DateTime. Closes #546.
Diffstat (limited to 'boto/ec2/autoscale/launchconfig.py')
-rw-r--r-- | boto/ec2/autoscale/launchconfig.py | 16 |
1 files changed, 7 insertions, 9 deletions
diff --git a/boto/ec2/autoscale/launchconfig.py b/boto/ec2/autoscale/launchconfig.py index 2f55b248..8811fb6b 100644 --- a/boto/ec2/autoscale/launchconfig.py +++ b/boto/ec2/autoscale/launchconfig.py @@ -19,11 +19,11 @@ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS # IN THE SOFTWARE. - from datetime import datetime -import base64 from boto.resultset import ResultSet from boto.ec2.elb.listelement import ListElement +import boto.utils +import base64 # this should use the corresponding object from boto.ec2 class Ebs(object): @@ -70,7 +70,8 @@ class BlockDeviceMapping(object): self.ebs = None def __repr__(self): - return 'BlockDeviceMapping(%s, %s)' % (self.device_name, self.virtual_name) + return 'BlockDeviceMapping(%s, %s)' % (self.device_name, + self.virtual_name) def startElement(self, name, attrs, connection): if name == 'Ebs': @@ -83,7 +84,6 @@ class BlockDeviceMapping(object): elif name == 'VirtualName': self.virtual_name = value - class LaunchConfiguration(object): def __init__(self, connection=None, name=None, image_id=None, key_name=None, security_groups=None, user_data=None, @@ -150,7 +150,8 @@ class LaunchConfiguration(object): if name == 'SecurityGroups': return self.security_groups elif name == 'BlockDeviceMappings': - self.block_device_mappings = ResultSet([('member', BlockDeviceMapping)]) + self.block_device_mappings = ResultSet([('member', + BlockDeviceMapping)]) return self.block_device_mappings elif name == 'InstanceMonitoring': self.instance_monitoring = InstanceMonitoring(self) @@ -166,10 +167,7 @@ class LaunchConfiguration(object): elif name == 'ImageId': self.image_id = value elif name == 'CreatedTime': - try: - self.created_time = datetime.strptime(value, '%Y-%m-%dT%H:%M:%S.%fZ') - except ValueError: - self.created_time = datetime.strptime(value, '%Y-%m-%dT%H:%M:%SZ') + self.created_time = boto.utils.parse_ts(value) elif name == 'KernelId': self.kernel_id = value elif name == 'RamdiskId': |