From 39140bc3c760ee0b6d1887a585811bdcf667cfa5 Mon Sep 17 00:00:00 2001 From: bjschuma Date: Fri, 22 Jan 2010 23:16:57 -0500 Subject: [PATCH] Replaced disable, enable, reload, and lsmod with one plugin --- src/base/settings.py | 2 ++ src/core/disable.py | 26 -------------- src/core/enable.py | 23 ------------ src/core/plugins.py | 72 ++++++++++++++++++++++++++++++++++++++ src/core/reload.py | 23 ------------ src/extra/guiGTK/window.py | 8 ++--- src/extra/lsmod.py | 34 ------------------ src/extra/sgtk.py | 7 ++-- 8 files changed, 83 insertions(+), 112 deletions(-) delete mode 100644 src/core/disable.py delete mode 100644 src/core/enable.py create mode 100644 src/core/plugins.py delete mode 100644 src/core/reload.py delete mode 100644 src/extra/lsmod.py diff --git a/src/base/settings.py b/src/base/settings.py index f883dc42..548378da 100644 --- a/src/base/settings.py +++ b/src/base/settings.py @@ -35,6 +35,8 @@ from bt import xm # Return the value at key def get(key): key = key.upper() + if has(key) == False: + return None return settings[key] diff --git a/src/core/disable.py b/src/core/disable.py deleted file mode 100644 index 5d59a562..00000000 --- a/src/core/disable.py +++ /dev/null @@ -1,26 +0,0 @@ -# This is a simple test plugin, to make sure everything is working - -__author__="bjschuma" -__date__ ="$Jan 20, 2010 7:51:32 PM$" - - -from bt import plugin -from manager import manager - - -class Plugin(plugin.Plugin): - def __init__(self): - plugin.Plugin.__init__(self) - self.help = "Used to disable plugins" - - - def run(self,args=None): - if args == None: - return - - dont = ["disable", "enable", "exit"] - for plugin in args: - # Only disable if plugin is not in the "do not disable" list - if not (plugin in dont): - manager.disablePlugin(plugin) - diff --git a/src/core/enable.py b/src/core/enable.py deleted file mode 100644 index 5ef1f33b..00000000 --- a/src/core/enable.py +++ /dev/null @@ -1,23 +0,0 @@ -# This is a simple test plugin, to make sure everything is working - -__author__="bjschuma" -__date__ ="$Jan 20, 2010 7:59:07 PM$" - - -from bt import plugin -from manager import manager - - -class Plugin(plugin.Plugin): - def __init__(self): - plugin.Plugin.__init__(self) - self.help = "This plugin is used to reenable other plugins" - - - def run(self, args=None): - if args == None: - return - - for plugin in args: - manager.enablePlugin(plugin) - diff --git a/src/core/plugins.py b/src/core/plugins.py new file mode 100644 index 00000000..3bbeb6ea --- /dev/null +++ b/src/core/plugins.py @@ -0,0 +1,72 @@ +# Basic plugin class + +__author__="bjschuma" +__date__ ="$Jan 22, 2010 12:14:01 AM$" + + +from bt.message import write +from bt import plugin +from manager import manager + + +class Plugin(plugin.Plugin): + def __init__(self): + plugin.Plugin.__init__(self) + self.help = "Enable, disable, or reload plugins" + self.usage = "Usage: plugins [enable, disable, reload, list]" + + + def list(self,args): + usage = "Usage: plugins list [enabled, disabled]" + if len(args) == 0: + write(usage) + return + + if args[0] == "enabled": + enabled = True + elif args[0] == "disabled": + enabled = False + else: + write(usage) + return + + if enabled == True: + list = manager.enabled.keys() + type = "Enabled" + else: + list = manager.disabled.keys() + type = "Disabled" + + if len(list) == 0: + write("Nothing to list") + return + + write(type + " plugins") + write("----------------") + join = ", " + joined = join.join(list) + write(joined) + return list + + + + def run(self, args=None): + if args == None: + write(self.usage) + return + + if args[0] == "enable": + func = manager.enablePlugin + elif args[0] == "disable": + func = manager.disablePlugin + elif args[0] == "reload": + func = manager.reloadPlugin + elif args[0] == "list": + return self.list(args[1:]) + else: + write(self.usage) + return + + for plugin in args[1:]: + func(plugin) + diff --git a/src/core/reload.py b/src/core/reload.py deleted file mode 100644 index ae153c84..00000000 --- a/src/core/reload.py +++ /dev/null @@ -1,23 +0,0 @@ -# Basic plugin class - -__author__="bjschuma" -__date__ ="$Jan 21, 2010 12:11:23 PM$" - - -from bt import plugin -from manager import manager - - -class Plugin(plugin.Plugin): - def __init__(self): - plugin.Plugin.__init__(self) - self.help = "Closes, then reopens a plugin" - - - def run(self, args=None): - if args == None: - return - - for plugin in args: - manager.reloadPlugin(plugin) - diff --git a/src/extra/guiGTK/window.py b/src/extra/guiGTK/window.py index 2cb9011c..8061ecac 100644 --- a/src/extra/guiGTK/window.py +++ b/src/extra/guiGTK/window.py @@ -61,7 +61,7 @@ class PluginWindow(Window): self.vbox.pack(self.hbox,True,True) self.add(self.vbox) - settings.set("write",empty) + #settings.set("write",empty) self.enabled = list.List(gtk.ListStore(str), ["Enabled"]) self.enabled.connect("cursor-changed", self.changeLabel, "enabled") @@ -75,7 +75,7 @@ class PluginWindow(Window): for mod in disabledMods: self.disabled.insert([mod]) - settings.pop("write") + #settings.pop("write") enable = button.Button("button",self.enable,None,"<<<") disable = button.Button("button", self.disable,None,">>>") @@ -123,7 +123,7 @@ class PluginWindow(Window): else: list, path, plugin = self.getPlugin(self.disabled) - settings.set("write", empty) + #settings.set("write", empty) message = manager.run("help",[plugin]) self.lbl.change(message) - settings.pop("write") + #settings.pop("write") diff --git a/src/extra/lsmod.py b/src/extra/lsmod.py deleted file mode 100644 index fffddc6b..00000000 --- a/src/extra/lsmod.py +++ /dev/null @@ -1,34 +0,0 @@ -# This is a simple test plugin, to make sure everything is working - -__author__="bjschuma" -__date__ ="$Dec 27, 2009 6:35:45 PM$" - - -from bt.message import write -from manager import manager -from bt import plugin - - -class Plugin(plugin.Plugin): - def __init__(self): - plugin.Plugin.__init__(self) - self.help = "Used to list currently loaded plugins" - - - def run(self, args=None): - mods = [] - if (args == None) or (("enabled" in args)==True) or (("all" in args)==True): - for plugin in manager.enabled.keys(): - mods += [plugin] - - if not(args==None) and ( (("disabled" in args) == True) or (("all" in args)==True) ): - for plugin in manager.disabled.keys(): - mods += [plugin] - - if len(mods) == 0: - return - comma = ', ' - list = comma.join(mods) - write(list) - - return mods diff --git a/src/extra/sgtk.py b/src/extra/sgtk.py index aa758f8a..5a29f805 100644 --- a/src/extra/sgtk.py +++ b/src/extra/sgtk.py @@ -25,14 +25,17 @@ class Plugin(plugin.Plugin): def open(self): - settings.set("guirunning",False) + #settings.set("guirunning",False) if settings.get("guirunning") == True: signal.register("run",self.loop) signal.register("quit",self.close) + else: + settings.set("guirunning",False) def close(self): - gtk.main_quit() + if settings.get("guirunning") == True: + gtk.main_quit() settings.delete("gtkfuncs")