Commit 1f2ee67d authored by Yingjie Xu's avatar Yingjie Xu

Simplify file reading and catch exception for type converting.

parent 5f722223
...@@ -575,14 +575,15 @@ class Slapgrid(object): ...@@ -575,14 +575,15 @@ class Slapgrid(object):
self.instance_root, computer_partition_id) self.instance_root, computer_partition_id)
timestamp_path = os.path.join(instance_path, '.timestamp') timestamp_path = os.path.join(instance_path, '.timestamp')
if os.path.exists(timestamp_path): if os.path.exists(timestamp_path):
descriptor = open(timestamp_path) old_timestamp = open(timestamp_path).read()
old_timestamp = int(descriptor.read())
descriptor.close()
parameter_dict = computer_partition.getInstanceParameterDict() parameter_dict = computer_partition.getInstanceParameterDict()
if 'timestamp' in parameter_dict: if 'timestamp' in parameter_dict:
timestamp = int(parameter_dict['timestamp']) timestamp = parameter_dict['timestamp']
if timestamp <= old_timestamp: try:
continue if int(timestamp) <= int(old_timestamp):
continue
except ValueError:
pass
try: try:
software_url = computer_partition.getSoftwareRelease().getURI() software_url = computer_partition.getSoftwareRelease().getURI()
except NotFoundError: except NotFoundError:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment