Esempio n. 1
0
    def do_show(self, line):
        """
        Show a plugin's variable.
        Usage show [plugin] [variable]

        If the variable is ommited, then all the variable will be shown.
        """
        if line == "":
            self.stdout.write("Show what?")

        try:
            plugin, name = line.split()
        except:
            plugin = line

        plugin = plugin_manager.getPluginByName(plugin)
        if plugin == None:
            return

        plugin = plugin.plugin_object

        l = plugin.get_variables()
        if l == None:
            self.stdout.write("This plugin has no variables.")
        else:
            v = [ "%s %s" % (key, value) for key, value in l.items() ]
            self.print_topics("Variables", v, 40, self.wrap)
Esempio n. 2
0
    def default(self, line):
        """
        When a command is not understood, it goes here.
        """

        try:
            l = line.split()
            plugin, cmd = l[:2]
        except (ValueError, IndexError):
            self.syntax_error(line)
            return

        try:
            args = l[2:]
        except IndexError:
            pass
        else:
            args = []

        
        plugin = plugin_manager.getPluginByName(plugin)
        plugin = plugin.plugin_object
        try:
            f = getattr(plugin, "cmd_" + cmd)
        except AttributeError:
            self.stdout.write("*** Plugin \"%s\" has no command: %s\n" % (plugin.name, cmd))
        else:
            f(args)
Esempio n. 3
0
    def do_set(self, line):
        """
        Set a plugin's variable.
        Usage: set [plugin] [variable] [value]
        """
        try:
            plugin, name, value = line.split()
        except:
            return

        plugin = plugin_manager.getPluginByName(plugin)
        if plugin == None:
            return

        plugin.plugin_object.set(name, value)
        self.stdout.write("ok.")