Example #1
0
    def interactiveSetup(self):
        """ Interactive setup script.
        """
        print()
        console.writeln(_("Entering setup menu for profile {0}.").format(self.profile), console.color("G", True, ""))
        self.setupWorkDir()

        choice = ""
        choices = []
        choices.append(_("Exit"))
        choices.append(_("General options"))
        choices.append("Geocaching.com")
        choices.append(_("Output"))
        choices.append(_("Enable/Disable plugins"))
        choices.append(_("Plugins settings"))
        while choice != choices[0]:
            print()
            console.writeln(_("Main menu"), console.color("RB", True, ""))
            choice = console.menu(_("Action:"), choices)
            if choice == choices[1]:
                self.setupGeneral()
            elif choice == choices[2]:
                self.setupGeocachingCom()
            elif choice == choices[3]:
                self.setupOutput()
            elif choice == choices[4]:
                self.setupPlugins()
            elif choice == choices[5]:
                self.setupPluginsSettings()
        self.setupEnd()
Example #2
0
    def interactiveSetup(self):
        """ Interactive setup script.
        """
        print()
        console.writeln(
            _("Entering setup menu for profile {0}.").format(self.profile),
            console.color("G", True, ""))
        self.setupWorkDir()

        choice = ""
        choices = []
        choices.append(_("Exit"))
        choices.append(_("General options"))
        choices.append("Geocaching.com")
        choices.append(_("Output"))
        choices.append(_("Enable/Disable plugins"))
        choices.append(_("Plugins settings"))
        while choice != choices[0]:
            print()
            console.writeln(_("Main menu"), console.color("RB", True, ""))
            choice = console.menu(_("Action:"), choices)
            if choice == choices[1]:
                self.setupGeneral()
            elif choice == choices[2]:
                self.setupGeocachingCom()
            elif choice == choices[3]:
                self.setupOutput()
            elif choice == choices[4]:
                self.setupPlugins()
            elif choice == choices[5]:
                self.setupPluginsSettings()
        self.setupEnd()
Example #3
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 #4
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 #5
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 #6
0
        setup = "full"

    # Try to find selected profile
    choices = []
    if os.path.isdir(profilesDir):
        for name in os.listdir(profilesDir):
            if os.path.isdir(os.path.join(profilesDir, name)):
                choices.append(name)
    if opts.profile is None:
        if len(choices) == 1:
            profile = choices[0]
            rootlog.warn(_("No profile name given, auto-chosing the only available profile '{0}'.").format(profile))
        else:
            if len(choices) > 0:
                choices.insert(0, _("Create new"))
                profile = console.menu(_("No profile name given, please select your profile."), choices)
            if len(choices) == 0 or profile == choices[0]:
                profile = console.prompt(_("Profile name") + ":", validate=lambda val: None if val.isalnum() else _("Please, use only alpha-numeric characters."))
                setup = "full"
    else:
        profile = opts.profile
        if profile not in choices:
            rootlog.warn(_("Profile '{0}' does not exist, creating profile directory and initiating setup script.").format(profile))
            setup = "full"

    # Check if the upgrade script for profile data is needed
    if os.path.isdir(os.path.join(profilesDir, profile)):
        if os.path.isfile(os.path.join(profilesDir, profile, "version")):
            with open(os.path.join(profilesDir, profile, "version")) as fp:
                version = VersionInfo(fp.read())
        else:
Example #7
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 #8
0
    choices = []
    if os.path.isdir(profilesDir):
        for name in os.listdir(profilesDir):
            if os.path.isdir(os.path.join(profilesDir, name)):
                choices.append(name)
    if opts.profile is None:
        if len(choices) == 1:
            profile = choices[0]
            rootlog.warn(
                _("No profile name given, auto-chosing the only available profile '{0}'."
                  ).format(profile))
        else:
            if len(choices) > 0:
                choices.insert(0, _("Create new"))
                profile = console.menu(
                    _("No profile name given, please select your profile."),
                    choices)
            if len(choices) == 0 or profile == choices[0]:
                profile = console.prompt(
                    _("Profile name") + ":",
                    validate=lambda val: None if val.isalnum() else _(
                        "Please, use only alpha-numeric characters."))
                setup = "full"
    else:
        profile = opts.profile
        if profile not in choices:
            rootlog.warn(
                _("Profile '{0}' does not exist, creating profile directory and initiating setup script."
                  ).format(profile))
            setup = "full"