diff --git a/src/base/bt/plugin.py b/src/base/bt/plugin.py index 884a97ce..279f01df 100644 --- a/src/base/bt/plugin.py +++ b/src/base/bt/plugin.py @@ -34,6 +34,8 @@ class Plugin: def start(self,args=None): try: return self.run(args) + + # Find out information about the error except: trace = inspect.trace() frame = trace[len(trace)-1] @@ -41,14 +43,8 @@ class Plugin: filename = frame[1] lineno = str(frame[2]) - - #filename = frame[1] - #lineno = str(inspect.currentframe().f_back.f_lineno) - #filename = inspect.currentframe().f_forward.f_code.co_filename filename = filename.rsplit(os.sep,1)[1] write(filename+" ("+lineno+")") - #print e - def run(self,args=None): diff --git a/src/base/settings.py b/src/base/settings.py index ac8d34d6..f883dc42 100644 --- a/src/base/settings.py +++ b/src/base/settings.py @@ -123,7 +123,7 @@ write("Setting default values...", True) # Find who is running the program user = os.path.expanduser("~") set("USER", user) -set("PLUGPATH", ["../core" ]) #, "../extra"]) +set("PLUGPATH", ["../core", "../extra"]) # Find out what platform we are running on set("ARCH", sys.platform) diff --git a/src/core/help.py b/src/core/help.py index ddd4c170..adde2510 100644 --- a/src/core/help.py +++ b/src/core/help.py @@ -14,6 +14,7 @@ class Plugin(plugin.Plugin): plugin.Plugin.__init__(self) self.help = "Returns a short description of the plugin" + def run(self, args=None): if args == None: plugin = "help" diff --git a/src/extra/example.py b/src/extra/example.py index d0313f42..034e11bf 100644 --- a/src/extra/example.py +++ b/src/extra/example.py @@ -4,31 +4,21 @@ __author__="bjschuma" __date__ ="$Dec 7, 2009 9:12:00 AM$" -global name, app, type, path, opt -name = "test" -app = "scion" -type = "extra" -path = "" -opt = [] +from bt import plugin from bt.message import write -# Called every time the plugin is enabled -def open(): - write("Example plugin has been started",True) - #write("Example plugin has been changed",True) +class Plugin(plugin.Plugin): + def __init__(self): + plugin.Plugin.__init__(self) + self.help = "An example plugin." -# Called every time the plugin is stopped -def close(): - write("Example plugin has been stopped",True) + def open(self): + write("Example plugin has been started",True) + #write("Example plugin has been changed",True) -def help(): - return "Just a simple example plugin" - - -# Called when the plugin needs to perform some action -def run(args=None): - pass + def close(self): + write("Example plugin has been stopped",True) diff --git a/src/extra/lsmod.py b/src/extra/lsmod.py index 879615da..fffddc6b 100644 --- a/src/extra/lsmod.py +++ b/src/extra/lsmod.py @@ -4,46 +4,31 @@ __author__="bjschuma" __date__ ="$Dec 27, 2009 6:35:45 PM$" -global name, app, type, path, opt -name = "lsmod" -app = "scion" -type = "extra" -path = "" -opt = [] - from bt.message import write from manager import manager +from bt import plugin -# Called every time the plugin is enabled -def open(): - pass +class Plugin(plugin.Plugin): + def __init__(self): + plugin.Plugin.__init__(self) + self.help = "Used to list currently loaded plugins" -# Called every time the plugin is stopped -def close(): - pass + 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] -def help(): - return "Used to list currently loaded plugins" + if len(mods) == 0: + return + comma = ', ' + list = comma.join(mods) + write(list) - -# Called when the plugin needs to perform some action -def run(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 + return mods diff --git a/src/extra/lsset.py b/src/extra/lsset.py index 1625d2aa..1f00eb04 100644 --- a/src/extra/lsset.py +++ b/src/extra/lsset.py @@ -4,40 +4,26 @@ __author__="bjschuma" __date__ ="$Jan 9, 2010 7:22:31 PM$" -global name, app, type, path, opt -name = "lsset" -app = "scion" -type = "extra" -path = "" -opt = [] from bt.message import write import settings +from bt import plugin -# Called every time the plugin is enabled -def open(): - pass +class Plugin(plugin.Plugin): + def __init__(self): + plugin.Plugin.__init__(self) + self.help = "Used to show the current state of settings" -# Called every time the plugin is stopped -def close(): - pass + def run(self, args=None): + keys = settings.settings.keys() + join = ", " - -def help(): - return "Used to show the current state of settings" - - -# Called when the plugin needs to perform some action -def run(args=None): - keys = settings.settings.keys() - join = ", " - - if args == None: - str = join.join(keys) - write(str) - else: - if settings.has(args[0]) == True: - write( settings.get(args[0], True) ) + if args == None: + str = join.join(keys) + write(str) + else: + if settings.has(args[0]) == True: + write( settings.get(args[0], True) ) diff --git a/src/extra/sgtk.py b/src/extra/sgtk.py index ffa38d71..aa758f8a 100644 --- a/src/extra/sgtk.py +++ b/src/extra/sgtk.py @@ -4,13 +4,8 @@ __author__="bjschuma" __date__ ="$Jan 13, 2010 12:02:58 AM$" -global name, app, type, path, opt -name = "sgtk" -app = "scion" -type = "extra" -path = "" -opt = [] +from bt import plugin from bt.message import write from bt import signal from manager import manager @@ -23,76 +18,60 @@ global vbox global bar -def test(button, name): - write("Test!") +class Plugin(plugin.Plugin): + def __init__(self): + plugin.Plugin.__init__(self) + self.help = "Allows the usage of GTK" -def pluginWindow(item): - plugins = window.PluginWindow() + def open(self): + settings.set("guirunning",False) + if settings.get("guirunning") == True: + signal.register("run",self.loop) + signal.register("quit",self.close) -def loop(): - global vbox,bar,win - manager.run("disable",["cli"]) + def close(self): + gtk.main_quit() + settings.delete("gtkfuncs") - win = window.Window(settings.get("appname").title()) - vbox = box.VBox() - win.add(vbox) - - bar = menu.Bar() - vbox.pack(bar) - plugins = menu.Item("Plugins",pluginWindow) - - tools = menu.Item("Tools",None,[plugins]) - bar.append(tools) - #vbox.pack(tabs.Tabs()) - - #but = button.Button("button",test,None,"I'm a button!") - #vbox.pack(but) - - #lab = label.Label("Hello, World!") - #vbox.pack(lab) - if settings.has("gtkfuncs") == True: - for func in settings.get("gtkfuncs", True): - func([win,vbox,bar]) - - settings.set("guirunning",True) - gtk.main() + + def run(self, args=None): + global win,box + if args == None: + self.loop() + elif args[0] == "getwin": + return win + elif args[0] == "getbox": + return box -# Called every time the plugin is stopped -def close(): - gtk.main_quit() - settings.delete("gtkfuncs") - pass + def test(self, button, name): + write("Test!") -# Called every time the plugin is enabled -def open(): - settings.set("guirunning",False) - #settings.init("gtkfuncs", []) - if settings.get("guirunning") == True: - signal.register("run",loop) - signal.register("quit",close) - #1settings.set("loop",loop) - pass + def pluginWindow(self, item): + plugins = window.PluginWindow() + def loop(self): + global vbox,bar,win + manager.run("disable",["cli"]) + win = window.Window(settings.get("appname").title()) + vbox = box.VBox() + win.add(vbox) + bar = menu.Bar() + vbox.pack(bar) + plugins = menu.Item("Plugins",self.pluginWindow) -def help(): - return "Allows the usage of GTK" - - -# Called when the plugin needs to perform some action -def run(args=None): - global win,box - if args == None: - loop() - elif args[0] == "getwin": - return win - elif args[0] == "getbox": - return box + tools = menu.Item("Tools",None,[plugins]) + bar.append(tools) + if settings.has("gtkfuncs") == True: + for func in settings.get("gtkfuncs", True): + func([win,vbox,bar]) + settings.set("guirunning",True) + gtk.main()