From 0cadbf33815736b9f4ca09b36e2c72c1fbd6c06c Mon Sep 17 00:00:00 2001 From: Natalia Serrano Date: Wed, 28 Aug 2024 15:11:49 +0200 Subject: [PATCH] refs #579 do not load modules unconditionally, look for everything in the module paths --- src/cfg/ogagent.cfg | 4 ++-- src/opengnsys/loader.py | 5 ++--- .../modules}/server/ogAdmClient/__init__.py | 0 3 files changed, 4 insertions(+), 5 deletions(-) rename src/{test_modules => opengnsys/modules}/server/ogAdmClient/__init__.py (100%) diff --git a/src/cfg/ogagent.cfg b/src/cfg/ogagent.cfg index be977a2..96f4da0 100644 --- a/src/cfg/ogagent.cfg +++ b/src/cfg/ogagent.cfg @@ -4,7 +4,7 @@ address=0.0.0.0 port=8000 # This is a comma separated list of paths where to look for modules to load -path=test_modules/server +#path=test_modules/server,more_modules/server # Remote OpenGnsys Service remote=https://192.168.2.10/opengnsys/rest @@ -21,7 +21,7 @@ log=DEBUG # The sections must match the module name # This section will be passes on activation to module [ogAdmClient] -#path=test_modules/server +#path=test_modules/server,more_modules/server ## this URL will probably be left equal to the other one, but let's see remote=https://192.168.2.10/opengnsys/rest log=DEBUG diff --git a/src/opengnsys/loader.py b/src/opengnsys/loader.py index 577fcf7..a1c0211 100644 --- a/src/opengnsys/loader.py +++ b/src/opengnsys/loader.py @@ -35,6 +35,7 @@ # Modules under "opengsnsys/modules" are always autoloaded +import sys import pkgutil import os.path @@ -55,12 +56,10 @@ def loadModules(controller, client=False): ogModules = [] if client is False: - from opengnsys.modules.server import OpenGnSys # @UnusedImport from .modules import server # @UnusedImport, just used to ensure opengnsys modules are initialized modPath = 'opengnsys.modules.server' modType = ServerWorker else: - from opengnsys.modules.client import OpenGnSys # @UnusedImport @Reimport from .modules import client # @UnusedImport, just used to ensure opengnsys modules are initialized modPath = 'opengnsys.modules.client' modType = ClientWorker @@ -98,7 +97,7 @@ def loadModules(controller, client=False): else: paths = () - # paths += (os.path.dirname(sys.modules[modPath].__file__),) + paths += (os.path.dirname(sys.modules[modPath].__file__),) # Load modules logger.debug('Loading modules from {}'.format(paths)) diff --git a/src/test_modules/server/ogAdmClient/__init__.py b/src/opengnsys/modules/server/ogAdmClient/__init__.py similarity index 100% rename from src/test_modules/server/ogAdmClient/__init__.py rename to src/opengnsys/modules/server/ogAdmClient/__init__.py