Finished moving to new event system
This commit is contained in:
parent
3f8a023813
commit
9bfe8b903b
|
@ -7,7 +7,6 @@ __author__="bjschuma"
|
|||
__date__ ="$Jan 23, 2010 2:33:21 PM$"
|
||||
|
||||
from bt.file import *
|
||||
from bt import signal
|
||||
from bt import dict
|
||||
import session
|
||||
|
||||
|
@ -16,7 +15,7 @@ class Alias(dict.Dict):
|
|||
def __init__(self):
|
||||
dict.Dict.__init__(self)
|
||||
session.events.invite("scion-plugins-loaded",self.load,3)
|
||||
signal.register("scion-end",self.save,90)
|
||||
session.events.invite("scion-end",self.save,90)
|
||||
|
||||
|
||||
def save(self):
|
||||
|
|
|
@ -2,4 +2,4 @@
|
|||
# It contains various tools needed by the base layer of ocarina2
|
||||
|
||||
__all__ = ["cmd", "dict", "event", "file", "map", "message", "needle", "plugin",
|
||||
"proc", "scripting", "signal", "slist", "sql", "xm"]
|
||||
"proc", "scripting", "slist", "sql", "xm"]
|
|
@ -4,10 +4,7 @@ __author__="bjschuma"
|
|||
__date__ ="$Dec 5, 2009 6:46:13 PM$"
|
||||
|
||||
import os
|
||||
#import inspect
|
||||
#from session import session
|
||||
import session
|
||||
import bt.signal
|
||||
|
||||
global enabled
|
||||
enabled = True
|
||||
|
|
|
@ -5,7 +5,6 @@ __date__ ="$Dec 5, 2009 6:33:50 PM$"
|
|||
|
||||
import session
|
||||
from message import write
|
||||
from bt import signal
|
||||
from bt.file import join
|
||||
|
||||
# Set our process name to name
|
||||
|
|
|
@ -11,9 +11,9 @@ global scripts
|
|||
import re
|
||||
scripts = []
|
||||
|
||||
from bt.signal import register
|
||||
from bt import file
|
||||
from bt.message import write
|
||||
import session
|
||||
|
||||
global extension
|
||||
extension = ["scion","py"]
|
||||
|
@ -58,7 +58,7 @@ def runScripts():
|
|||
def checkForScripts():
|
||||
global scripts
|
||||
if len(scripts) > 0:
|
||||
register("scion-begin",runScripts,0)
|
||||
session.events.invite("scion-begin",runScripts,0)
|
||||
|
||||
|
||||
# If the given file is a script, we add it to the script list
|
||||
|
@ -70,5 +70,5 @@ def isScript(script):
|
|||
scripts += [script]
|
||||
|
||||
|
||||
register("scion-plugins-loaded",checkForScripts)
|
||||
register("scion-process-args",isScript)
|
||||
session.events.invite("scion-plugins-loaded",checkForScripts)
|
||||
session.events.invite("scion-process-args",isScript)
|
|
@ -1,62 +0,0 @@
|
|||
#! /usr/bin/python
|
||||
|
||||
# To change this template, choose Tools | Templates
|
||||
# and open the template in the editor.
|
||||
|
||||
__author__="bjschuma"
|
||||
__date__ ="$Jan 20, 2010 12:13:21 AM$"
|
||||
|
||||
from map import Map
|
||||
global signals, status, scripts
|
||||
signals = Map()
|
||||
status = dict()
|
||||
scripts = dict()
|
||||
|
||||
|
||||
def attachScript(signal,script):
|
||||
global scripts
|
||||
if (signal in scripts) == False:
|
||||
scripts[signal] = [script]
|
||||
else:
|
||||
scripts[signal] += [script]
|
||||
|
||||
|
||||
def register(signal,func,priority=100):
|
||||
if signals.has(signal) == False:
|
||||
status[signal] = False
|
||||
signals.set(signal,(priority,func))
|
||||
|
||||
|
||||
def remove(signal,func):
|
||||
global signals
|
||||
signals.remove(signal,func)
|
||||
|
||||
|
||||
def stop(signal):
|
||||
status[signal] = False
|
||||
|
||||
|
||||
def emit(signal,args=None):
|
||||
if signals.has(signal) == False:
|
||||
return
|
||||
|
||||
funcs = signals.get(signal,True)
|
||||
i = 0
|
||||
status[signal] = True
|
||||
|
||||
for priority,func in funcs:
|
||||
if status[signal] == True:
|
||||
if not args==None:
|
||||
func(args)
|
||||
else:
|
||||
func()
|
||||
else:
|
||||
break
|
||||
|
||||
stop(signal)
|
||||
|
||||
if (signal in scripts) == True:
|
||||
import scripting
|
||||
for script in scripts[signal]:
|
||||
scripting.runScript(script)
|
||||
|
|
@ -5,7 +5,6 @@ __date__ ="$Dec 8, 2009 8:40:36 AM$"
|
|||
import sys
|
||||
from bt.message import *
|
||||
from bt.file import *
|
||||
from bt.signal import *
|
||||
|
||||
import session
|
||||
import inspect
|
||||
|
@ -14,7 +13,7 @@ class Manager:
|
|||
def __init__(self):
|
||||
write("Creating plugin manager", 1)
|
||||
session.events.invite("scion-plugins-loaded",self.startup)
|
||||
register("scion-end",self.shutdown,0)
|
||||
session.events.invite("scion-end",self.shutdown,0)
|
||||
# Map the plugin name to a dictionary
|
||||
self.enabled = dict()
|
||||
self.disabled = dict()
|
||||
|
|
|
@ -3,7 +3,6 @@ __date__ ="$Dec 4, 2009 3:37:21 PM$"
|
|||
|
||||
# We need to import settings before we can use disp()
|
||||
import session
|
||||
from bt.signal import emit
|
||||
|
||||
# Import the plugin loader class!
|
||||
import loader
|
||||
|
@ -20,7 +19,7 @@ def main():
|
|||
loadPluginPath(path)
|
||||
|
||||
session.events.start("scion-plugins-loaded")
|
||||
emit("scion-begin")
|
||||
session.events.start("scion-begin")
|
||||
|
||||
|
||||
if __name__ == "__main__":main()
|
||||
|
|
|
@ -16,7 +16,6 @@ from settings import Settings
|
|||
from aliases import Alias
|
||||
from bt.file import *
|
||||
from bt.message import write
|
||||
from bt import signal
|
||||
from manager import Manager
|
||||
from bt import proc
|
||||
|
||||
|
@ -54,7 +53,7 @@ def parseInput():
|
|||
elif (opt[0]=="-v") or (opt[0]=="--verbose"):
|
||||
settings["verbose"] += 1
|
||||
for arg in args:
|
||||
signal.emit("scion-process-args",arg)
|
||||
events.start("scion-process-args",arg)
|
||||
#settings["args"] = args
|
||||
except getopt.GetoptError, e:
|
||||
write(e.msg)
|
||||
|
|
|
@ -10,7 +10,6 @@ from sys import argv,platform
|
|||
import os
|
||||
|
||||
from bt.message import write
|
||||
from bt import signal
|
||||
from bt.file import join
|
||||
from bt import xm
|
||||
from bt import dict
|
||||
|
|
|
@ -5,10 +5,12 @@ cli-loop-begin:
|
|||
Started in plugins.cline.loop.loop(), at the beginning of every loop
|
||||
|
||||
|
||||
|
||||
cli-loop-end:
|
||||
Started in plugins.cline.loop.loop(), at the end of every loop
|
||||
|
||||
|
||||
|
||||
message-write:
|
||||
Started in bt.message.py to print a message
|
||||
Stopped in plugins.cline.message.insert()
|
||||
|
@ -23,13 +25,47 @@ message-write:
|
|||
|
||||
|
||||
|
||||
scion-begin:
|
||||
Started in core/scion.py to begin a loop
|
||||
|
||||
core.bt.scripting.runScripts()
|
||||
Invited in core.bt.scripting.checkForScripts(), Priority 0
|
||||
Runs all scripts
|
||||
|
||||
extra.sgtk.Plugin.loop()
|
||||
Invited in extra.sgtk.Plugin.open(), Priority 90
|
||||
Begins a gtk main loop
|
||||
|
||||
plugins.cline.loop.loop()
|
||||
Invited in plugins.cli.Plugin.open(), Default priority
|
||||
Removed in plugins.cli.Plugin.close()
|
||||
Sets the command line loop and the default start function
|
||||
|
||||
|
||||
scion-end:
|
||||
Started to begin the shutdown procedure
|
||||
Started in plugins.exit.run() to begin the shutdown procedure
|
||||
|
||||
core.manager.Manager.shutdown()
|
||||
Invited in core.manager.Manager.__init__(), Priority 0
|
||||
Disables and saves all active plugins
|
||||
|
||||
extra.sgtk.Plugin.close()
|
||||
Invited in extra.sgtk.Plugin.open(), Priority 90
|
||||
Stops the gtk main loop
|
||||
|
||||
core.aliases.Alias.save()
|
||||
Invited in core.aliases.Alias.__init__(), Priority 90
|
||||
Saves aliases to a file to be read in on next startup
|
||||
|
||||
core.settings.Settings.save()
|
||||
Invited in core.settings.Settings.__init__(), Default priority
|
||||
Saves all settings key/value pairs to a file
|
||||
|
||||
plugins.cline.loop.quit()
|
||||
Invited in plugins.cli.Plugin.open(), Default priority
|
||||
Removed in plugins.cli.Plugin.close()
|
||||
Reverts ncurses stuff
|
||||
|
||||
|
||||
|
||||
scion-plugins-loaded:
|
||||
|
@ -54,3 +90,16 @@ scion-plugins-loaded:
|
|||
core.manager.startup()
|
||||
Invited in core.manager.Manager.__init__(), Default priority
|
||||
Enables the plugins that the user had enabled before the last shutdown
|
||||
|
||||
core.bt.scripting.checkForScripts()
|
||||
Invited in core.bt.scripting, Default priority
|
||||
Checks if scripts have been registered on startup
|
||||
|
||||
|
||||
|
||||
scion-process-args:
|
||||
Started in core/session.py when we are given arguments
|
||||
|
||||
core.bt.scripting.isScript()
|
||||
Invited in core.bt.scripting, Default priority
|
||||
Checks if a file is a script
|
|
@ -6,7 +6,7 @@ __date__ ="$Feb 7, 2010 7:19:45 PM$"
|
|||
|
||||
from bt import plugin
|
||||
from bt.message import write
|
||||
from bt import signal
|
||||
import session
|
||||
|
||||
|
||||
class Plugin(plugin.Plugin):
|
||||
|
@ -17,7 +17,7 @@ class Plugin(plugin.Plugin):
|
|||
|
||||
def run(self, args=None):
|
||||
if args==None or len(args)==0:
|
||||
write(signal.signals.keys())
|
||||
write(session.events.keys())
|
||||
else:
|
||||
write(signal.signals.get(args[0],True))
|
||||
write(session.events[args[0]])
|
||||
|
||||
|
|
|
@ -7,11 +7,12 @@ __date__ ="$Jan 13, 2010 12:02:58 AM$"
|
|||
|
||||
from bt import plugin
|
||||
from bt.message import write
|
||||
from bt import signal
|
||||
#from bt import signal
|
||||
#from manager import manager
|
||||
from session import settings,manager
|
||||
from guiGTK import *
|
||||
import gtk
|
||||
from session import events
|
||||
|
||||
global win
|
||||
global vbox
|
||||
|
@ -26,10 +27,9 @@ class Plugin(plugin.Plugin):
|
|||
|
||||
|
||||
def open(self):
|
||||
#settings.set("guirunning",False)
|
||||
if settings["guirunning"] == True:
|
||||
signal.register("scion-begin",self.loop,90)
|
||||
signal.register("scion-end",self.close,90)
|
||||
events.invite("scion-begin",self.loop,90)
|
||||
events.invite("scion-end",self.close,90)
|
||||
else:
|
||||
settings["guirunning"] = False
|
||||
|
||||
|
@ -37,9 +37,6 @@ class Plugin(plugin.Plugin):
|
|||
def close(self):
|
||||
if settings["guirunning"] == True:
|
||||
gtk.main_quit()
|
||||
#del settings["gtkfuncs"]
|
||||
signal.remove("scion-begin",self.loop)
|
||||
signal.remove("scion-end",self.close)
|
||||
|
||||
|
||||
def run(self, args=None):
|
||||
|
|
|
@ -5,8 +5,6 @@ __date__ ="$Jan 20, 2010 7:37:39 PM$"
|
|||
|
||||
|
||||
from bt import plugin
|
||||
#from bt.needle import Needle
|
||||
from bt.signal import *
|
||||
from bt.message import *
|
||||
|
||||
import cline.loop
|
||||
|
@ -15,7 +13,7 @@ import cline.message
|
|||
import cline.history
|
||||
|
||||
from session import settings
|
||||
#import settings
|
||||
from session import events
|
||||
|
||||
|
||||
|
||||
|
@ -31,8 +29,8 @@ class Plugin(plugin.Plugin):
|
|||
cline.history.read()
|
||||
|
||||
# Register our run function and close function
|
||||
register("scion-begin", cline.loop.loop)
|
||||
register("scion-end", cline.loop.quit)
|
||||
events.invite("scion-begin", cline.loop.loop)
|
||||
events.invite("scion-end", cline.loop.quit)
|
||||
|
||||
# Initialize a dictionary for key press inputs
|
||||
settings["keyinput"] = dict()
|
||||
|
@ -47,8 +45,8 @@ class Plugin(plugin.Plugin):
|
|||
cline.history.save()
|
||||
write("CLI has been stopped", 1)
|
||||
del settings["keyinput"]
|
||||
remove("scion-begin",cline.loop.loop)
|
||||
remove("scion-end",cline.loop.quit)
|
||||
events.uninvite("scion-begin",cline.loop.loop)
|
||||
events.uninvite("scion-end",cline.loop.quit)
|
||||
|
||||
|
||||
def run(self,args):
|
||||
|
|
|
@ -7,7 +7,7 @@ __author__="bjschuma"
|
|||
__date__ ="$Jan 20, 2010 6:42:45 PM$"
|
||||
|
||||
from bt import plugin
|
||||
from bt.signal import emit
|
||||
import session
|
||||
|
||||
|
||||
class Plugin(plugin.Plugin):
|
||||
|
@ -18,6 +18,6 @@ class Plugin(plugin.Plugin):
|
|||
|
||||
|
||||
def run(self,args=None):
|
||||
emit("scion-end")
|
||||
session.events.start("scion-end")
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue