Support listing images in subdirectories

It's a part of the OVA support:
https://github.com/GNS3/gns3-gui/issues/700
This commit is contained in:
Julien Duponchelle
2015-10-05 11:07:15 +02:00
parent dd7f6eb021
commit 034ac392b7
11 changed files with 84 additions and 79 deletions

View File

@ -439,15 +439,15 @@ class BaseManager:
:returns: Array of hash
"""
try:
files = os.listdir(self.get_images_directory())
except FileNotFoundError:
return []
files.sort()
images = []
for filename in files:
if filename[0] != "." and not filename.endswith(".md5sum"):
images.append({"filename": filename})
img_dir = self.get_images_directory()
for root, dirs, files in os.walk(img_dir):
for filename in files:
if filename[0] != "." and not filename.endswith(".md5sum"):
path = os.path.relpath(os.path.join(root, filename), img_dir)
images.append({
"filename": filename,
"path": path})
return images
def get_images_directory(self):