Began scripting
This commit is contained in:
parent
e731c3bc41
commit
6fba352109
|
@ -2,4 +2,4 @@
|
|||
# It contains various tools needed by the base layer of ocarina2
|
||||
|
||||
__all__ = ["alias", "file", "map", "message", "needle", "plugin", "proc",
|
||||
"signal", "sql", "xm"]
|
||||
"scripting", "signal", "sql", "xm"]
|
|
@ -0,0 +1,51 @@
|
|||
#! /usr/bin/python
|
||||
|
||||
# To change this template, choose Tools | Templates
|
||||
# and open the template in the editor.
|
||||
|
||||
__author__="bjschuma"
|
||||
__date__ ="$Feb 16, 2010 11:56:00 PM$"
|
||||
|
||||
|
||||
global scripts
|
||||
scripts = []
|
||||
|
||||
from bt.message import write
|
||||
from bt.signal import *
|
||||
from bt import file
|
||||
import manager
|
||||
|
||||
|
||||
def add(script):
|
||||
global scripts
|
||||
scripts += [script]
|
||||
|
||||
|
||||
def runScript(script):
|
||||
f = file.fopen(script)
|
||||
for line in f:
|
||||
write(line.strip(),True)
|
||||
split = line.split(';')
|
||||
for word in split:
|
||||
cmd = word.strip().split()
|
||||
if len(cmd)>1:
|
||||
manager.run(cmd[0],cmd[1:])
|
||||
else:
|
||||
manager.run(line)
|
||||
#write(line.strip())
|
||||
|
||||
|
||||
def runScripts():
|
||||
#write(scripts)
|
||||
for script in scripts:
|
||||
runScript(script)
|
||||
manager.run("exit")
|
||||
|
||||
|
||||
def checkForScripts():
|
||||
global scripts
|
||||
if len(scripts) > 0:
|
||||
register("scion-begin",runScripts,50)
|
||||
|
||||
|
||||
register("scion-plugins-loaded",checkForScripts)
|
|
@ -31,6 +31,8 @@ def main():
|
|||
for path in settings.get("PLUGPATH"):
|
||||
loadPluginPath(path)
|
||||
|
||||
emit("scion-plugins-loaded")
|
||||
|
||||
app = settings.get("appname")
|
||||
write("Welcome to "+app+"!")
|
||||
setname(app)
|
||||
|
|
|
@ -25,13 +25,6 @@ def set(key,value):
|
|||
settings[key] = value
|
||||
|
||||
|
||||
from bt.message import write
|
||||
from bt.message import error
|
||||
from bt.file import fopen
|
||||
from bt.file import join
|
||||
from bt import xm
|
||||
|
||||
|
||||
# Return the value at key
|
||||
def get(key):
|
||||
key = key.upper()
|
||||
|
@ -40,6 +33,17 @@ def get(key):
|
|||
return settings[key]
|
||||
|
||||
|
||||
from bt.message import write
|
||||
from bt.message import error
|
||||
from bt.file import fopen
|
||||
from bt.file import join
|
||||
from bt import xm
|
||||
from bt import scripting
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
def delete(key):
|
||||
key = key.upper()
|
||||
if has(key) == True:
|
||||
|
@ -57,8 +61,8 @@ def parseInput():
|
|||
write("Parsing user input",True)
|
||||
input = sys.argv[1:]
|
||||
write(input,True)
|
||||
optc = "vp:"
|
||||
long = ["verbose", "path="]
|
||||
optc = "vp:s:"
|
||||
long = ["verbose", "path=", "script="]
|
||||
|
||||
# Attempt to parse user input
|
||||
try:
|
||||
|
@ -66,7 +70,8 @@ def parseInput():
|
|||
for opt in opts:
|
||||
if opt[0] == "-p":
|
||||
set("plugpath",get("plugpath")+[opt[1]])
|
||||
#set("PLUGPATH", opt[1])
|
||||
elif opt[0] == "-s":
|
||||
scripting.add(opt[1])
|
||||
set("ARGS", args)
|
||||
except getopt.GetoptError, e:
|
||||
error(e.msg)
|
||||
|
@ -127,7 +132,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)
|
||||
|
|
|
@ -7,4 +7,7 @@ Scion 1.3 New Features
|
|||
|
||||
2 / 16 / 2010
|
||||
- Rename signals
|
||||
- About plugin to give scion version information
|
||||
- About plugin to give scion version information
|
||||
|
||||
2 / 17 / 2010
|
||||
- Began scripting
|
|
@ -36,3 +36,10 @@ scion-end:
|
|||
Removed in core.cli.Plugin.close()
|
||||
Removed in extra.sgtk.Plugin.close()
|
||||
|
||||
|
||||
scion-plugins-loaded:
|
||||
Called right after loading all the plugins (before restoring settings or
|
||||
enabling any plugins)
|
||||
Emitted in scion.main()
|
||||
|
||||
|
||||
|
|
|
@ -5,7 +5,7 @@ Scion To-Do List
|
|||
- Add more signals
|
||||
- Scripting
|
||||
- Check during startup, register as callback if some token in first line
|
||||
- Run script if given as an input arg, then exit
|
||||
- Run script if given as an input arg, then exit (2/17/2010)
|
||||
- Run script after a signal has executed
|
||||
- Variables (dict with name->string)
|
||||
- *.scion == scripts. Allow adding to list of extensions
|
||||
|
@ -25,5 +25,5 @@ Scion To-Do List
|
|||
- Scripts
|
||||
- Better way to list signals, aliases, and settings
|
||||
- Command line options for plugins
|
||||
- Command line optionss to disable signals and/or scripting
|
||||
- Command line options to disable signals and/or scripting
|
||||
- Plugin sub-function help ("help plugins disable")
|
||||
|
|
Loading…
Reference in New Issue