ocarina/src/base/bt/scripting.py

51 lines
877 B
Python

#! /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)