From 3804249d8908d5832ab0bfcce72f69902878da88 Mon Sep 17 00:00:00 2001 From: grossmj Date: Fri, 30 Dec 2022 10:01:43 +0800 Subject: [PATCH] Fix tests --- gns3server/controller/__init__.py | 9 +++++---- gns3server/controller/appliance_manager.py | 9 +++++---- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/gns3server/controller/__init__.py b/gns3server/controller/__init__.py index 4b8a5001..e53227d8 100644 --- a/gns3server/controller/__init__.py +++ b/gns3server/controller/__init__.py @@ -289,10 +289,11 @@ class Controller: shutil.copy(os.path.join(resource_path, filename), os.path.join(dst_path, filename)) else: for entry in importlib_resources.files('gns3server.configs').iterdir(): - full_path = os.path.join(dst_path, entry.name) - if entry.is_file() and not os.path.exists(full_path): - log.debug(f"Installing base config file {entry.name} to {full_path}") - shutil.copy(str(entry), os.path.join(dst_path, entry.name)) + if entry.is_file(): + full_path = os.path.join(dst_path, entry.name) + if not os.path.exists(full_path): + log.debug(f"Installing base config file {entry.name} to {full_path}") + shutil.copy(str(entry), os.path.join(dst_path, entry.name)) except OSError as e: log.error(f"Could not install base config files to {dst_path}: {e}") diff --git a/gns3server/controller/appliance_manager.py b/gns3server/controller/appliance_manager.py index ea2b294a..c1d79e7f 100644 --- a/gns3server/controller/appliance_manager.py +++ b/gns3server/controller/appliance_manager.py @@ -105,10 +105,11 @@ class ApplianceManager: shutil.copy(os.path.join(resource_path, filename), os.path.join(dst_path, filename)) else: for entry in importlib_resources.files('gns3server.appliances').iterdir(): - full_path = os.path.join(dst_path, entry.name) - if entry.is_file() and not os.path.exists(full_path): - log.debug(f"Installing built-in appliance file {entry.name} to {full_path}") - shutil.copy(str(entry), os.path.join(dst_path, entry.name)) + if entry.is_file(): + full_path = os.path.join(dst_path, entry.name) + if not os.path.exists(full_path): + log.debug(f"Installing built-in appliance file {entry.name} to {full_path}") + shutil.copy(str(entry), os.path.join(dst_path, entry.name)) except OSError as e: log.error(f"Could not install built-in appliance files to {dst_path}: {e}")