diff --git a/src/Plugin/PluginManager.py b/src/Plugin/PluginManager.py index 4854b218..36cc3486 100644 --- a/src/Plugin/PluginManager.py +++ b/src/Plugin/PluginManager.py @@ -40,11 +40,12 @@ class PluginManager: # Load all plugin def loadPlugins(self): + all_loaded = True s = time.time() for dir_name in sorted(os.listdir(self.plugin_path)): dir_path = os.path.join(self.plugin_path, dir_name) if dir_name == "__pycache__": - continue # skip + continue # skip if dir_name.startswith("disabled"): continue # Dont load if disabled if not os.path.isdir(dir_path): @@ -56,12 +57,14 @@ class PluginManager: __import__(dir_name) except Exception as err: self.log.error("Plugin %s load error: %s" % (dir_name, Debug.formatException(err))) + all_loaded = False if dir_name not in self.plugin_names: self.plugin_names.append(dir_name) self.log.debug("Plugins loaded in %.3fs" % (time.time() - s)) for func in self.after_load: func() + return all_loaded # Reload all plugins def reloadPlugins(self): @@ -153,6 +156,13 @@ def acceptPlugins(base_class): # Register plugin to class name decorator def registerTo(class_name): + if config.debug: + import gc + for obj in gc.get_objects(): + if type(obj).__name__ == class_name: + raise Exception("Class %s instances already present in memory" % class_name) + break + plugin_manager.log.debug("New plugin registered to: %s" % class_name) if class_name not in plugin_manager.plugins: plugin_manager.plugins[class_name] = [] diff --git a/src/Test/conftest.py b/src/Test/conftest.py index 9a664451..1db8bd69 100644 --- a/src/Test/conftest.py +++ b/src/Test/conftest.py @@ -78,7 +78,9 @@ config.data_dir = TEST_DATA_PATH # Use test data for unittests os.chdir(os.path.abspath(os.path.dirname(__file__) + "/../..")) # Set working dir -PluginManager.plugin_manager.loadPlugins() +all_loaded = PluginManager.plugin_manager.loadPlugins() +assert all_loaded, "There was error loading plugins" + config.loadPlugins() config.parse() # Parse again to add plugin configuration options