Added echo and exec commands, scripting can now run a python script.
This commit is contained in:
parent
a8c4b67aff
commit
acdcca152e
|
@ -0,0 +1,9 @@
|
|||
#! /usr/bin/python
|
||||
|
||||
# To change this template, choose Tools | Templates
|
||||
# and open the template in the editor.
|
||||
|
||||
__author__="bjschuma"
|
||||
__date__ ="$Feb 22, 2010 10:52:13 PM$"
|
||||
|
||||
|
|
@ -16,7 +16,7 @@ from bt import file
|
|||
from bt.message import write
|
||||
|
||||
global extension
|
||||
extension = ["scion"]
|
||||
extension = ["scion","py"]
|
||||
|
||||
|
||||
def add(script):
|
||||
|
@ -25,11 +25,17 @@ def add(script):
|
|||
|
||||
|
||||
def runScript(script):
|
||||
from bt import cmd
|
||||
f = file.fopen(script)
|
||||
for line in f:
|
||||
cmd.run(line)
|
||||
f.close()
|
||||
# Run commands if the script is not a python script
|
||||
if re.match("\w*\.py",script) == None:
|
||||
from bt import cmd
|
||||
f = file.fopen(script)
|
||||
for line in f:
|
||||
cmd.run(line)
|
||||
f.close()
|
||||
# Execute the script with the python interpreter as a backend
|
||||
else:
|
||||
execfile(script)
|
||||
|
||||
|
||||
|
||||
def runScripts():
|
||||
|
|
|
@ -0,0 +1,23 @@
|
|||
# Basic plugin class
|
||||
|
||||
__author__="bjschuma"
|
||||
__date__ ="$Feb 21, 2010 11:06:41 PM$"
|
||||
|
||||
|
||||
from bt import plugin
|
||||
from bt.message import write
|
||||
|
||||
|
||||
class Plugin(plugin.Plugin):
|
||||
def __init__(self):
|
||||
plugin.Plugin.__init__(self)
|
||||
self.help = "Print text to the screen"
|
||||
|
||||
|
||||
def run(self, args=None):
|
||||
if args == None:
|
||||
return
|
||||
join = ' '
|
||||
message = join.join(args)
|
||||
write(message)
|
||||
|
|
@ -0,0 +1,36 @@
|
|||
# Basic plugin class
|
||||
|
||||
__author__="bjschuma"
|
||||
__date__ ="$Feb 24, 2010 6:18:54 PM$"
|
||||
|
||||
|
||||
from bt import plugin
|
||||
from bt.message import write
|
||||
import session
|
||||
|
||||
|
||||
class Plugin(plugin.Plugin):
|
||||
def __init__(self):
|
||||
plugin.Plugin.__init__(self)
|
||||
self.help = "Use to run python commands"
|
||||
self.usage = "exec [command, file file.py]"
|
||||
|
||||
|
||||
def open(self):
|
||||
pass
|
||||
|
||||
|
||||
def close(self):
|
||||
pass
|
||||
|
||||
|
||||
def run(self, args=None):
|
||||
if args==None:
|
||||
return
|
||||
|
||||
join = ' '
|
||||
if (len(args)>1) and (args[0].lower()=="file"):
|
||||
execfile(join.join(args[1:]))
|
||||
return
|
||||
exec(join.join(args))
|
||||
|
Loading…
Reference in New Issue