Modified all extra plugins for new interface

This commit is contained in:
bjschuma 2010-01-22 00:02:05 -05:00
parent 7de5fbfd39
commit e485b1e187
7 changed files with 89 additions and 152 deletions

View File

@ -34,6 +34,8 @@ class Plugin:
def start(self,args=None): def start(self,args=None):
try: try:
return self.run(args) return self.run(args)
# Find out information about the error
except: except:
trace = inspect.trace() trace = inspect.trace()
frame = trace[len(trace)-1] frame = trace[len(trace)-1]
@ -41,14 +43,8 @@ class Plugin:
filename = frame[1] filename = frame[1]
lineno = str(frame[2]) 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] filename = filename.rsplit(os.sep,1)[1]
write(filename+" ("+lineno+")") write(filename+" ("+lineno+")")
#print e
def run(self,args=None): def run(self,args=None):

View File

@ -123,7 +123,7 @@ write("Setting default values...", True)
# Find who is running the program # Find who is running the program
user = os.path.expanduser("~") user = os.path.expanduser("~")
set("USER", user) set("USER", user)
set("PLUGPATH", ["../core" ]) #, "../extra"]) set("PLUGPATH", ["../core", "../extra"])
# Find out what platform we are running on # Find out what platform we are running on
set("ARCH", sys.platform) set("ARCH", sys.platform)

View File

@ -14,6 +14,7 @@ class Plugin(plugin.Plugin):
plugin.Plugin.__init__(self) plugin.Plugin.__init__(self)
self.help = "Returns a short description of the plugin" self.help = "Returns a short description of the plugin"
def run(self, args=None): def run(self, args=None):
if args == None: if args == None:
plugin = "help" plugin = "help"

View File

@ -4,31 +4,21 @@ __author__="bjschuma"
__date__ ="$Dec 7, 2009 9:12:00 AM$" __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 from bt.message import write
# Called every time the plugin is enabled class Plugin(plugin.Plugin):
def open(): def __init__(self):
write("Example plugin has been started",True) plugin.Plugin.__init__(self)
#write("Example plugin has been changed",True) self.help = "An example plugin."
# Called every time the plugin is stopped def open(self):
def close(): write("Example plugin has been started",True)
write("Example plugin has been stopped",True) #write("Example plugin has been changed",True)
def help(): def close(self):
return "Just a simple example plugin" write("Example plugin has been stopped",True)
# Called when the plugin needs to perform some action
def run(args=None):
pass

View File

@ -4,46 +4,31 @@ __author__="bjschuma"
__date__ ="$Dec 27, 2009 6:35:45 PM$" __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 bt.message import write
from manager import manager from manager import manager
from bt import plugin
# Called every time the plugin is enabled class Plugin(plugin.Plugin):
def open(): def __init__(self):
pass plugin.Plugin.__init__(self)
self.help = "Used to list currently loaded plugins"
# Called every time the plugin is stopped def run(self, args=None):
def close(): mods = []
pass 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(): if len(mods) == 0:
return "Used to list currently loaded plugins" return
comma = ', '
list = comma.join(mods)
write(list)
return mods
# 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

View File

@ -4,40 +4,26 @@ __author__="bjschuma"
__date__ ="$Jan 9, 2010 7:22:31 PM$" __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 from bt.message import write
import settings import settings
from bt import plugin
# Called every time the plugin is enabled class Plugin(plugin.Plugin):
def open(): def __init__(self):
pass plugin.Plugin.__init__(self)
self.help = "Used to show the current state of settings"
# Called every time the plugin is stopped def run(self, args=None):
def close(): keys = settings.settings.keys()
pass join = ", "
if args == None:
def help(): str = join.join(keys)
return "Used to show the current state of settings" write(str)
else:
if settings.has(args[0]) == True:
# Called when the plugin needs to perform some action write( settings.get(args[0], True) )
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) )

View File

@ -4,13 +4,8 @@ __author__="bjschuma"
__date__ ="$Jan 13, 2010 12:02:58 AM$" __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.message import write
from bt import signal from bt import signal
from manager import manager from manager import manager
@ -23,76 +18,60 @@ global vbox
global bar global bar
def test(button, name): class Plugin(plugin.Plugin):
write("Test!") def __init__(self):
plugin.Plugin.__init__(self)
self.help = "Allows the usage of GTK"
def pluginWindow(item): def open(self):
plugins = window.PluginWindow() settings.set("guirunning",False)
if settings.get("guirunning") == True:
signal.register("run",self.loop)
signal.register("quit",self.close)
def loop(): def close(self):
global vbox,bar,win gtk.main_quit()
manager.run("disable",["cli"]) settings.delete("gtkfuncs")
win = window.Window(settings.get("appname").title())
vbox = box.VBox() def run(self, args=None):
win.add(vbox) global win,box
if args == None:
bar = menu.Bar() self.loop()
vbox.pack(bar) elif args[0] == "getwin":
plugins = menu.Item("Plugins",pluginWindow) return win
elif args[0] == "getbox":
tools = menu.Item("Tools",None,[plugins]) return box
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()
# Called every time the plugin is stopped def test(self, button, name):
def close(): write("Test!")
gtk.main_quit()
settings.delete("gtkfuncs")
pass
# Called every time the plugin is enabled def pluginWindow(self, item):
def open(): plugins = window.PluginWindow()
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 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(): tools = menu.Item("Tools",None,[plugins])
return "Allows the usage of GTK" bar.append(tools)
# 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
if settings.has("gtkfuncs") == True:
for func in settings.get("gtkfuncs", True):
func([win,vbox,bar])
settings.set("guirunning",True)
gtk.main()