def testConfigurationFileExistence(self): """ Test if the configuration file has been properly written. """ # activate the only loaded plugin self.plugin_activate() # get rid of the plugin manager and create a new one del self.pluginManager del self.config_parser self.config_parser = ConfigParser() self.config_parser.read(self.config_file) self.assertTrue(self.config_parser.has_section("Plugin Management")) self.assertTrue( self.config_parser.has_option("Plugin Management", "default_plugins_to_load")) self.pluginManager = ConfigurablePluginManager( directories_list=[ os.path.join(os.path.dirname(os.path.abspath(__file__)), "plugins") ], plugin_info_ext="yapsy-config-plugin", configparser_instance=self.config_parser, config_change_trigger=self.update_config) self.pluginManager.collectPlugins() self.plugin_loading_check() self.assertTrue(self.plugin_info.plugin_object.is_activated) self.pluginManager.deactivatePluginByName(self.plugin_info.name, self.plugin_info.category) # check that activating the plugin once again, won't cause an error self.pluginManager.activatePluginByName(self.plugin_info.name, self.plugin_info.category) # Will be used later self.plugin_info = None
def init_plugin_manager(self): # Configuring plugin locator plugin_locator = PluginFileLocator() plugin_locator.setPluginPlaces(PLUGIN_PLACES) # Initializing plugin manager... # categories_filter={"Default": IPlugin, "Custom": ICustomPlugin}, self._plmanager = PluginManager( categories_filter={"Default": IAlgorithmPlugin}, plugin_locator=plugin_locator) # decorate plugin manager with configurable feature self._cpmanager = ConfigurablePluginManager( decorated_manager=self._plmanager) # create parser for config file config_parser = ConfigParser() # set config file location config_parser.read(get_config_file_path()) # set parser to configurable decorator self._cpmanager.setConfigParser( configparser_instance=config_parser, config_change_trigger=config_change_trigger) # plugin_manager.collectPlugins() # configurable_plugin_manager.loadPlugins() self._cpmanager.collectPlugins() self.plugins_info() for plugin_info in self._plmanager.getAllPlugins(): if plugin_info.is_activated: plugin_info.plugin_object.set_image_manager(self._immanager)
def __init__(self, bus: Bus, config: Config, graph: Graph): self._bus = bus self._graph = graph logger.debug("action=init paths=%s", config.plugin_paths()) self._plugin_manager = ConfigurablePluginManager( decorated_manager=VersionedPluginManager()) self._plugin_manager.setPluginPlaces(config.plugin_paths()) self._plugin_manager.setPluginInfoExtension("plugin") self._plugin_manager.setConfigParser(config.parser, config.save)
def setUp(self): """ init """ # create a config file self.config_file = self.CONFIG_FILE self.config_parser = ConfigParser.SafeConfigParser() self.plugin_info = None # create the plugin manager self.pluginManager = ConfigurablePluginManager( directories_list=[os.path.join( os.path.dirname(os.path.abspath(__file__)),"plugins")], plugin_info_ext="yapsy-config-plugin", configparser_instance=self.config_parser, config_change_trigger=self.update_config) # load the plugins that may be found self.pluginManager.collectPlugins()
def testConfigurationFileExistence(self): """ Test if the configuration file has been properly written. """ # activate the only loaded plugin self.plugin_activate() # get rid of the plugin manager and create a new one del self.pluginManager del self.config_parser self.config_parser = ConfigParser.SafeConfigParser() self.config_parser.read(self.config_file) self.assert_(self.config_parser.has_section("Plugin Management")) self.assert_(self.config_parser.has_option("Plugin Management", "default_plugins_to_load")) self.pluginManager = ConfigurablePluginManager( directories_list=[os.path.join( os.path.dirname(os.path.abspath(__file__)),"plugins")], plugin_info_ext="yapsy-config-plugin", configparser_instance=self.config_parser, config_change_trigger=self.update_config) # Will be used later self.plugin_info = None