1
0
mirror of https://github.com/GNS3/gns3-server synced 2024-11-19 06:48:10 +00:00

Handle broken appliance files

Fix #1135
This commit is contained in:
Julien Duponchelle 2017-07-20 16:10:56 +02:00
parent 46e5e8ac68
commit c96694105c
No known key found for this signature in database
GPG Key ID: CE8B29639E07F5E8

View File

@ -71,10 +71,15 @@ class Controller:
):
if os.path.isdir(directory):
for file in os.listdir(directory):
if not file.endswith('.gns3a') and not file.endswith('.gns3appliance'):
continue
path = os.path.join(directory, file)
appliance_id = uuid.uuid3(uuid.NAMESPACE_URL, path) # Generate the UUID from path to avoid change between reboots
with open(path, 'r', encoding='utf-8') as f:
appliance = ApplianceTemplate(appliance_id, json.load(f), builtin=builtin)
try:
with open(path, 'r', encoding='utf-8') as f:
appliance = ApplianceTemplate(appliance_id, json.load(f), builtin=builtin)
except (ValueError, OSError) as e:
log.warning("Can't load %s: %s", path, str(e))
if appliance.status != 'broken':
self._appliance_templates[appliance.id] = appliance