quixey / python-aliyun

Python API client for Aliyun, the Alibaba Cloud.
Apache License 2.0
37 stars 24 forks source link

instance_id error #37

Open 467754239 opened 7 years ago

467754239 commented 7 years ago

get_instance(instance_id)

errormsg:

ValueError Traceback (most recent call last)

in () ----> 1 conn.get_instance(instance_ids[0]) /data/xxxx/lib/python2.7/site-packages/Aliyun-1.1.0-py2.7.egg/aliyun/ecs/connection.pyc in get_instance(self, instance_id) 184 int(resp['InternetMaxBandwidthOut']), 185 dateutil.parser.parse(resp['CreationTime']), --> 186 dateutil.parser.parse(resp['ExpiredTime']), 187 resp['InstanceChargeType'], 188 resp['Description'], /data/xxx/lib/python2.7/site-packages/python_dateutil-2.6.0-py2.7.egg/dateutil/parser.pyc in parse(timestr, parserinfo, **kwargs) 1166 return parser(parserinfo).parse(timestr, **kwargs) 1167 else: -> 1168 return DEFAULTPARSER.parse(timestr, **kwargs) 1169 1170 /data/xxx/lib/python2.7/site-packages/python_dateutil-2.6.0-py2.7.egg/dateutil/parser.pyc in parse(self, timestr, default, ignoretz, tzinfos, **kwargs) 560 561 if len(res) == 0: --> 562 raise ValueError("String does not contain a date.") 563 564 repl = {} ValueError: String does not contain a date.
bayodesegun commented 6 years ago

This error is coming from Line 186 of aliyun.ecs.connection.py, in the get_instance() method:

dateutil.parser.parse(resp['ExpiredTime']),

ExpiredTime will return an empty string if the instance has no ExpiredTime (this is very common).

This line of code can be improved to check this, I'll submit a pull request for that ASAP.