From 5bcc247881690daff649934ae557bc963d9b425c Mon Sep 17 00:00:00 2001 From: grossmj Date: Fri, 30 Dec 2022 11:37:34 +0800 Subject: [PATCH] Make gns3server.appliances a package --- gns3server/appliances/__init__.py | 0 gns3server/controller/__init__.py | 12 +++++------- gns3server/controller/appliance_manager.py | 12 +++++------- 3 files changed, 10 insertions(+), 14 deletions(-) create mode 100644 gns3server/appliances/__init__.py diff --git a/gns3server/appliances/__init__.py b/gns3server/appliances/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/gns3server/controller/__init__.py b/gns3server/controller/__init__.py index 12286b2c..4b8a5001 100644 --- a/gns3server/controller/__init__.py +++ b/gns3server/controller/__init__.py @@ -41,7 +41,6 @@ from ..version import __version__ from .topology import load_topology from .gns3vm import GNS3VM from .gns3vm.gns3_vm_error import GNS3VMError -from gns3server import configs as gns3_configs import logging log = logging.getLogger(__name__) @@ -289,12 +288,11 @@ class Controller: if not os.path.exists(os.path.join(dst_path, filename)): shutil.copy(os.path.join(resource_path, filename), os.path.join(dst_path, filename)) else: - for entry in importlib_resources.files(gns3_configs).iterdir(): - 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)) + 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)) 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 4a3310bd..ea2b294a 100644 --- a/gns3server/controller/appliance_manager.py +++ b/gns3server/controller/appliance_manager.py @@ -32,7 +32,6 @@ except ImportError: from .appliance import Appliance from ..config import Config from ..utils.asyncio import locking -from gns3server import appliances as gns3_appliances import logging log = logging.getLogger(__name__) @@ -105,12 +104,11 @@ class ApplianceManager: if not os.path.exists(os.path.join(dst_path, filename)): shutil.copy(os.path.join(resource_path, filename), os.path.join(dst_path, filename)) else: - for entry in importlib_resources.files(gns3_appliances).iterdir(): - 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)) + 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)) except OSError as e: log.error(f"Could not install built-in appliance files to {dst_path}: {e}")