When importing a project fix the GNS3 version

This commit is contained in:
Julien Duponchelle
2016-07-22 11:43:14 +02:00
parent 9b499dc51e
commit 94a262cd46
7 changed files with 98 additions and 13 deletions

View File

@ -67,17 +67,19 @@ def export_project(project, temporary_dir, include_images=False):
z.write(path, os.path.relpath(path, project._path), compress_type=zipfile.ZIP_DEFLATED)
for compute in project.computes:
if compute.id == "vm":
if compute.id != "local":
compute_files = yield from compute.list_files(project)
for compute_file in compute_files:
if not _filter_files(compute_file["path"]):
(fp, temp_path) = tempfile.mkstemp(dir=temporary_dir)
(fd, temp_path) = tempfile.mkstemp(dir=temporary_dir)
f = open(fd, "wb", closefd=True)
stream = yield from compute.download_file(project, compute_file["path"])
while True:
data = yield from stream.read(512)
if not data:
break
fp.write(data)
f.write(data)
f.close()
z.write(temp_path, arcname=compute_file["path"], compress_type=zipfile.ZIP_DEFLATED)
return z
@ -102,7 +104,6 @@ def _filter_files(path):
return False
def _export_project_file(project, path, z, include_images):
"""
Take a project file (.gns3) and patch it for the export