Can run scripts again
This commit is contained in:
parent
956cfa5bee
commit
cfbbdca966
|
@ -10,9 +10,10 @@ __date__ ="$Feb 16, 2010 11:56:00 PM$"
|
||||||
global scripts
|
global scripts
|
||||||
scripts = []
|
scripts = []
|
||||||
|
|
||||||
from bt.signal import *
|
from bt.signal import register
|
||||||
from bt import file
|
from bt import file
|
||||||
from bt import cmd
|
from bt import cmd
|
||||||
|
from bt.message import write
|
||||||
|
|
||||||
|
|
||||||
def add(script):
|
def add(script):
|
||||||
|
@ -28,6 +29,7 @@ def runScript(script):
|
||||||
|
|
||||||
|
|
||||||
def runScripts():
|
def runScripts():
|
||||||
|
global scripts
|
||||||
for script in scripts:
|
for script in scripts:
|
||||||
runScript(script)
|
runScript(script)
|
||||||
cmd.run("exit")
|
cmd.run("exit")
|
||||||
|
@ -36,7 +38,7 @@ def runScripts():
|
||||||
def checkForScripts():
|
def checkForScripts():
|
||||||
global scripts
|
global scripts
|
||||||
if len(scripts) > 0:
|
if len(scripts) > 0:
|
||||||
register("scion-begin",runScripts,50)
|
register("scion-begin",runScripts,0)
|
||||||
|
|
||||||
|
|
||||||
register("scion-plugins-loaded",checkForScripts)
|
register("scion-plugins-loaded",checkForScripts)
|
|
@ -45,7 +45,7 @@ class Settings(dict):
|
||||||
|
|
||||||
|
|
||||||
def has(self,key):
|
def has(self,key):
|
||||||
return (key.upper() in self)
|
return (key.lower() in self)
|
||||||
|
|
||||||
|
|
||||||
def init(self,key,value):
|
def init(self,key,value):
|
||||||
|
@ -54,19 +54,19 @@ class Settings(dict):
|
||||||
|
|
||||||
|
|
||||||
def __setitem__(self,key,value):
|
def __setitem__(self,key,value):
|
||||||
key = key.upper()
|
key = key.lower()
|
||||||
dict.__setitem__(self,key,value)
|
dict.__setitem__(self,key,value)
|
||||||
|
|
||||||
|
|
||||||
def __getitem__(self,key):
|
def __getitem__(self,key):
|
||||||
key = key.upper()
|
key = key.lower()
|
||||||
if self.has(key)==True:
|
if self.has(key)==True:
|
||||||
return dict.__getitem__(self,key)
|
return dict.__getitem__(self,key)
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
|
||||||
def __delitem__(self,key):
|
def __delitem__(self,key):
|
||||||
dict.__delitem__(self,key.upper())
|
dict.__delitem__(self,key.lower())
|
||||||
|
|
||||||
|
|
||||||
def load(self):
|
def load(self):
|
||||||
|
|
|
@ -16,7 +16,7 @@ def loadPluginPath(path):
|
||||||
|
|
||||||
# Begin our main loop
|
# Begin our main loop
|
||||||
def main():
|
def main():
|
||||||
for path in session.settings.get("PLUGPATH"):
|
for path in session.settings["PLUGPATH"]:
|
||||||
loadPluginPath(path)
|
loadPluginPath(path)
|
||||||
|
|
||||||
emit("scion-plugins-loaded")
|
emit("scion-plugins-loaded")
|
||||||
|
|
|
@ -5,7 +5,8 @@
|
||||||
|
|
||||||
__author__="bjschuma"
|
__author__="bjschuma"
|
||||||
__date__ ="$Feb 17, 2010 9:18:50 PM$"
|
__date__ ="$Feb 17, 2010 9:18:50 PM$"
|
||||||
|
import sys
|
||||||
|
import getopt
|
||||||
|
|
||||||
from bt.settings import Settings
|
from bt.settings import Settings
|
||||||
from bt.alias import Alias
|
from bt.alias import Alias
|
||||||
|
@ -28,6 +29,27 @@ def setSession():
|
||||||
mkdir(path)
|
mkdir(path)
|
||||||
settings["session"] = path
|
settings["session"] = path
|
||||||
write("Using session: " + path,2)
|
write("Using session: " + path,2)
|
||||||
|
|
||||||
|
|
||||||
|
def parseInput():
|
||||||
|
from bt import scripting
|
||||||
|
write("Parsing user input",1)
|
||||||
|
input = sys.argv[1:]
|
||||||
|
write(input,True)
|
||||||
|
optc = "vp:s:"
|
||||||
|
long = ["verbose", "path=", "script="]
|
||||||
|
|
||||||
|
# Attempt to parse user input
|
||||||
|
try:
|
||||||
|
opts, args = getopt.getopt(input, optc, long)
|
||||||
|
for opt in opts:
|
||||||
|
if opt[0] == "-p":
|
||||||
|
settings["plugpath"] += [opt[1]]
|
||||||
|
elif opt[0] == "-s":
|
||||||
|
scripting.add(opt[1])
|
||||||
|
settings["args"] = args
|
||||||
|
except getopt.GetoptError, e:
|
||||||
|
write(e.msg)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -38,6 +60,8 @@ settings.setdefaults()
|
||||||
manager = Manager()
|
manager = Manager()
|
||||||
alias = Alias()
|
alias = Alias()
|
||||||
|
|
||||||
|
parseInput()
|
||||||
|
|
||||||
# Register functions to call when all plugins have been loaded
|
# Register functions to call when all plugins have been loaded
|
||||||
signal.register("scion-plugins-loaded",proc.setup,0)
|
signal.register("scion-plugins-loaded",proc.setup,0)
|
||||||
signal.register("scion-plugins-loaded",setSession,0)
|
signal.register("scion-plugins-loaded",setSession,1)
|
||||||
|
|
|
@ -1,26 +0,0 @@
|
||||||
import os.path
|
|
||||||
__author__="bjschuma"
|
|
||||||
__date__ ="$Dec 4, 2009 4:04:24 PM$"
|
|
||||||
|
|
||||||
|
|
||||||
# Parse the user input
|
|
||||||
def parseInput():
|
|
||||||
write("Parsing user input",True)
|
|
||||||
input = sys.argv[1:]
|
|
||||||
write(input,True)
|
|
||||||
optc = "vp:s:"
|
|
||||||
long = ["verbose", "path=", "script="]
|
|
||||||
|
|
||||||
# Attempt to parse user input
|
|
||||||
try:
|
|
||||||
opts, args = getopt.getopt(input, optc, long)
|
|
||||||
for opt in opts:
|
|
||||||
if opt[0] == "-p":
|
|
||||||
set("plugpath",get("plugpath")+[opt[1]])
|
|
||||||
elif opt[0] == "-s":
|
|
||||||
scripting.add(opt[1])
|
|
||||||
set("ARGS", args)
|
|
||||||
except getopt.GetoptError, e:
|
|
||||||
error(e.msg)
|
|
||||||
return
|
|
||||||
|
|
Loading…
Reference in New Issue