58 lines
1018 B
Python
58 lines
1018 B
Python
#! /usr/bin/python
|
|
|
|
# To change this template, choose Tools | Templates
|
|
# and open the template in the editor.
|
|
|
|
__author__="bjschuma"
|
|
__date__ ="$Feb 20, 2010 2:19:10 PM$"
|
|
|
|
from bt.message import *
|
|
from session import alias
|
|
from session import manager
|
|
|
|
|
|
|
|
def runCmd(input):
|
|
write("Running command: "+input,2)
|
|
|
|
# Find command
|
|
split = input.split(' ',1)
|
|
cmd = split[0]
|
|
args=None
|
|
if len(split) > 1:
|
|
args = split[1]
|
|
|
|
# Translate an alias to a command
|
|
if alias.has(cmd):
|
|
new = alias[cmd]
|
|
if args==None:
|
|
return runCmd(new)
|
|
else:
|
|
return runCmd(new+" "+args)
|
|
|
|
if (cmd in manager.enabled) == True:
|
|
if args == None:
|
|
return manager.enabled[cmd].start()
|
|
else:
|
|
return manager.enabled[cmd].start(args.split())
|
|
|
|
|
|
def run(string):
|
|
split = string.split(";")
|
|
ans = []
|
|
for command in split:
|
|
ans += [runCmd(command.strip())]
|
|
if len(ans) == 1:
|
|
return ans[0]
|
|
return ans
|
|
|
|
|
|
def call(string):
|
|
# disable text printing
|
|
disable()
|
|
result = run(string)
|
|
# enable text printing
|
|
enable()
|
|
return result
|
|
|