Fix error when you have error on your filesystem during project convertion

Fix #894
This commit is contained in:
Julien Duponchelle 2017-02-07 10:36:36 +01:00
parent 19b70accd5
commit f33e470601
No known key found for this signature in database
GPG Key ID: CE8B29639E07F5E8

View File

@ -163,11 +163,14 @@ def _convert_2_0_0_beta_2(topo, topo_path):
dynamips_dir = os.path.join(topo_dir, "project-files", "dynamips") dynamips_dir = os.path.join(topo_dir, "project-files", "dynamips")
node_dir = os.path.join(dynamips_dir, node_id) node_dir = os.path.join(dynamips_dir, node_id)
os.makedirs(os.path.join(node_dir, "configs"), exist_ok=True) try:
for path in glob.glob(os.path.join(glob.escape(dynamips_dir), "*_i{}_*".format(dynamips_id))): os.makedirs(os.path.join(node_dir, "configs"), exist_ok=True)
shutil.move(path, os.path.join(node_dir, os.path.basename(path))) for path in glob.glob(os.path.join(glob.escape(dynamips_dir), "*_i{}_*".format(dynamips_id))):
for path in glob.glob(os.path.join(glob.escape(dynamips_dir), "configs", "i{}_*".format(dynamips_id))): shutil.move(path, os.path.join(node_dir, os.path.basename(path)))
shutil.move(path, os.path.join(node_dir, "configs", os.path.basename(path))) for path in glob.glob(os.path.join(glob.escape(dynamips_dir), "configs", "i{}_*".format(dynamips_id))):
shutil.move(path, os.path.join(node_dir, "configs", os.path.basename(path)))
except OSError as e:
raise aiohttp.web.HTTPConflict(text="Can't convert project {}: {}".format(topo_path, str(e)))
return topo return topo