Example #1
0
 def setupPluginsSettings(self):
     """ Config of every enabled plugin
     """
     config = self.config
     choices = []
     choices.append(_("Exit"))
     plugins = config.options("plugins")
     plugins.sort()
     for plugin in list(plugins):
         self.loadPlugin(plugin)
         if hasattr(self.plugins[plugin], "setup"):
             choices.append("{0:25s} {1}".format(plugin, self.plugins[plugin].about))
         else:
             plugins.remove(plugin)
     while True:
         print()
         console.writeln("  " + _("Plugins settings menu"), console.color("RB", False, ""))
         choice = console.menu(_("Plugins:"), choices, padding=1)
         if choice == choices[0]:
             break
         plugin = plugins[choices.index(choice) - 1]
         console.write("  " + _("Configuration of") + " ", console.color("GB", False, ""))
         console.writeln(plugin, console.color("GB", True, ""))
         self.plugins[plugin].setup()
         config.save()
Example #2
0
 def setupPluginsSettings(self):
     """ Config of every enabled plugin
     """
     config = self.config
     choices = []
     choices.append(_("Exit"))
     plugins = config.options("plugins")
     plugins.sort()
     for plugin in list(plugins):
         self.loadPlugin(plugin)
         if hasattr(self.plugins[plugin], "setup"):
             choices.append("{0:25s} {1}".format(
                 plugin, self.plugins[plugin].about))
         else:
             plugins.remove(plugin)
     while True:
         print()
         console.writeln("  " + _("Plugins settings menu"),
                         console.color("RB", False, ""))
         choice = console.menu(_("Plugins:"), choices, padding=1)
         if choice == choices[0]:
             break
         plugin = plugins[choices.index(choice) - 1]
         console.write("  " + _("Configuration of") + " ",
                       console.color("GB", False, ""))
         console.writeln(plugin, console.color("GB", True, ""))
         self.plugins[plugin].setup()
         config.save()
Example #3
0
 def detectPlugins(self):
     """ Search for available plugins.
     """
     plugins = []
     for plugin in os.listdir(os.path.join(os.path.dirname(__file__), "plugins")):
         if plugin.endswith(".py") and not plugin.startswith("__init__") and not plugin.startswith("example") and plugin[:-3] != "base":
             plugins.append(plugin[:-3])
     plugins.sort()
     return plugins
Example #4
0
    def setupPlugins(self):
        """ Config: plugins section
        """
        config = self.config
        config.assertSection("plugins")
        print()
        console.writeln(_("Plugins"), console.color("G", True, ""))

        # Remove not installed plugins
        installedPlugins = self.detectPlugins()
        for plugin in config.options("plugins"):
            if plugin not in installedPlugins:
                logging.debug("Removing not installed plugin {0}.".format(plugin))
                config.remove_option("plugins", plugin)
        # Setup new found plugins
        for plugin in installedPlugins:
            if plugin not in config.options("plugins"):
                self.loadPlugin(plugin)
                console.writeln("  " + _("Plugin") + " " + plugin + ": " + self.plugins[plugin].about, console.color("G", False, ""))
                config.update("plugins", plugin, _("Enable") + " " + plugin + " ({CHOICES})?", validate=["y", "n"])
                if config.get("plugins", plugin) == "y":
                    self.setupPluginsEnable(plugin)
                print()
        config.save()

        plugins = config.options("plugins")
        plugins.sort()
        while True:
            choices = []
            choices.append(_("Exit"))
            for plugin in plugins:
                self.loadPlugin(plugin)
                if config.get("plugins", plugin) == "y":
                    choices.append("[x] {0:25s} {1}".format(plugin, self.plugins[plugin].about))
                else:
                    choices.append("[ ] {0:25s} {1}".format(plugin, self.plugins[plugin].about))
            print()
            console.writeln("  " + _("Enable/Disable plugins menu"), console.color("RB", False, ""))
            choice = console.menu(_("Plugins:"), choices, padding=1)
            if choice == choices[0]:
                break
            plugin = plugins[choices.index(choice) - 1]
            if config.get("plugins", plugin) == "y":
                block = []
                for bl in plugins:
                    if plugin in self.plugins[bl].dependencies:
                        block.append(bl)
                if len(block) > 0:
                    self.log.error(_("Cannot disable plugin {0}, because {1} depend on it.").format(plugin, ", ".join(block)))
                else:
                    print("  " + _("Disabling plugin {0}.").format(plugin))
                    config.set("plugins", plugin, "n")
            else:
                print("  " + _("Enabling plugin {0}.").format(plugin))
                config.set("plugins", plugin, "y")
                self.setupPluginsEnable(plugin)
            config.save()
Example #5
0
 def detectPlugins(self):
     """ Search for available plugins.
     """
     plugins = []
     for plugin in os.listdir(
             os.path.join(os.path.dirname(__file__), "plugins")):
         if plugin.endswith(".py") and not plugin.startswith(
                 "__init__") and not plugin.startswith(
                     "example") and plugin[:-3] != "base":
             plugins.append(plugin[:-3])
     plugins.sort()
     return plugins
Example #6
0
    def setupPlugins(self):
        """ Config: plugins section
        """
        config = self.config
        config.assertSection("plugins")
        print()
        console.writeln(_("Plugins"), console.color("G", True, ""))

        # Remove not installed plugins
        installedPlugins = self.detectPlugins()
        for plugin in config.options("plugins"):
            if plugin not in installedPlugins:
                logging.debug(
                    "Removing not installed plugin {0}.".format(plugin))
                config.remove_option("plugins", plugin)
        # Setup new found plugins
        for plugin in installedPlugins:
            if plugin not in config.options("plugins"):
                self.loadPlugin(plugin)
                console.writeln(
                    "  " + _("Plugin") + " " + plugin + ": " +
                    self.plugins[plugin].about, console.color("G", False, ""))
                config.update("plugins",
                              plugin,
                              _("Enable") + " " + plugin + " ({CHOICES})?",
                              validate=["y", "n"])
                if config.get("plugins", plugin) == "y":
                    self.setupPluginsEnable(plugin)
                print()
        config.save()

        plugins = config.options("plugins")
        plugins.sort()
        while True:
            choices = []
            choices.append(_("Exit"))
            for plugin in plugins:
                self.loadPlugin(plugin)
                if config.get("plugins", plugin) == "y":
                    choices.append("[x] {0:25s} {1}".format(
                        plugin, self.plugins[plugin].about))
                else:
                    choices.append("[ ] {0:25s} {1}".format(
                        plugin, self.plugins[plugin].about))
            print()
            console.writeln("  " + _("Enable/Disable plugins menu"),
                            console.color("RB", False, ""))
            choice = console.menu(_("Plugins:"), choices, padding=1)
            if choice == choices[0]:
                break
            plugin = plugins[choices.index(choice) - 1]
            if config.get("plugins", plugin) == "y":
                block = []
                for bl in plugins:
                    if plugin in self.plugins[bl].dependencies:
                        block.append(bl)
                if len(block) > 0:
                    self.log.error(
                        _("Cannot disable plugin {0}, because {1} depend on it."
                          ).format(plugin, ", ".join(block)))
                else:
                    print("  " + _("Disabling plugin {0}.").format(plugin))
                    config.set("plugins", plugin, "n")
            else:
                print("  " + _("Enabling plugin {0}.").format(plugin))
                config.set("plugins", plugin, "y")
                self.setupPluginsEnable(plugin)
            config.save()