Exemplo n.º 1
0
    def reload_plugin(self):
        """
        Reload plugin (import it and find hooks again)

        :return:
        """
        self.module = importlib.reload(self.module)
        self.config = parse_config(self.module)
        self.hooks = find_hooks(self.module)
Exemplo n.º 2
0
    def load_plugin(self, plugin_name):
        """
        Parse config, find hooks and create new Plugin object.

        :param plugin_name: name for plugin import
        :return:
        """
        plugin_name = plugin_name.strip()
        plugin_module = import_plugin(plugin_name)
        if not plugin_module:
            logger.error_message("'{}' plugin didn't load".format(
                plugin_name
            ))
            return
        plugin_config = parse_config(plugin_module)
        hooks, interval_hooks = find_hooks(plugin_module)

        plugin = Plugin(plugin_name, plugin_module, plugin_config,
                        hooks, interval_hooks)
        self.plugins.append(plugin)