From aad74dbcb9a60e7f9a59fb2e20fe09f0df08d73e Mon Sep 17 00:00:00 2001 From: grossmj Date: Wed, 10 Jul 2019 11:16:50 +0200 Subject: [PATCH] Add debug message when searching for an image. Ref https://github.com/GNS3/gns3-gui/issues/2828 --- gns3server/compute/base_manager.py | 8 ++++++-- gns3server/utils/images.py | 2 +- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/gns3server/compute/base_manager.py b/gns3server/compute/base_manager.py index 0eb6426a..23656a43 100644 --- a/gns3server/compute/base_manager.py +++ b/gns3server/compute/base_manager.py @@ -492,15 +492,17 @@ class BaseManager: # Windows path should not be send to a unix server if not sys.platform.startswith("win"): if re.match(r"^[A-Z]:", path) is not None: - raise NodeError("{} is not allowed on this remote server. Please use only a filename in {}.".format(path, img_directory)) + raise NodeError("{} is not allowed on this remote server. Please only use a file from '{}'".format(path, img_directory)) if not os.path.isabs(path): for directory in valid_directory_prefices: + log.debug("Searching for image '{}' in '{}'".format(orig_path, directory)) path = self._recursive_search_file_in_directory(directory, orig_path) if path: return force_unix_path(path) # Not found we try the default directory + log.debug("Searching for image '{}' in default directory".format(orig_path)) s = os.path.split(orig_path) path = force_unix_path(os.path.join(img_directory, *s)) if os.path.exists(path): @@ -509,6 +511,7 @@ class BaseManager: # For local server we allow using absolute path outside image directory if server_config.getboolean("local", False) is True: + log.debug("Searching for '{}'".format(orig_path)) path = force_unix_path(path) if os.path.exists(path): return path @@ -517,11 +520,12 @@ class BaseManager: # Check to see if path is an absolute path to a valid directory path = force_unix_path(path) for directory in valid_directory_prefices: + log.debug("Searching for image '{}' in '{}'".format(orig_path, directory)) if os.path.commonprefix([directory, path]) == directory: if os.path.exists(path): return path raise ImageMissingError(orig_path) - raise NodeError("{} is not allowed on this remote server. Please use only a filename in {}.".format(path, img_directory)) + raise NodeError("{} is not allowed on this remote server. Please only use a file from '{}'".format(path, img_directory)) def _recursive_search_file_in_directory(self, directory, searched_file): """ diff --git a/gns3server/utils/images.py b/gns3server/utils/images.py index 21bfb9a8..93420069 100644 --- a/gns3server/utils/images.py +++ b/gns3server/utils/images.py @@ -120,7 +120,7 @@ def default_images_directory(type): def images_directories(type): """ - Return all directory where we will look for images + Return all directories where we will look for images by priority :param type: Type of emulator