ocarina/src/core/scripting.py

39 lines
657 B
Python

#! /usr/bin/python
# To change this template, choose Tools | Templates
# and open the template in the editor.
__author__="bjschuma"
__date__ ="$Mar 14, 2010 7:33:16 PM$"
import re
from ct import cmd
import ocarina
def runOcaScript(file):
fin = open(file)
for line in fin:
# Do some formatting for each line
line = line.split("#",1)[0]
line = line.strip()
if len(line) > 0:
cmd.run(line)
def runScript(file):
if re.match("(.*?)\.py",file) == None:
runOcaScript(file)
else:
try:
execfile(file)
except:
print "Error in: " + file
def init():
runScript("corescr/init.oc")
ocarina.events.invite("ocarina-start",init,10)