We can exit and reload plugins from the command line
This commit is contained in:
parent
14cb66767f
commit
ea31ada3ce
|
@ -82,5 +82,9 @@ class Manager:
|
|||
self.disablePlugin(plugin)
|
||||
|
||||
|
||||
def run(self,name,args=None):
|
||||
self.enabled[name].run(args)
|
||||
|
||||
|
||||
global manager
|
||||
manager = Manager()
|
|
@ -37,8 +37,9 @@ def open():
|
|||
# Set these values in settings class for use elsewhere
|
||||
settings.set("stdscr", stdscr)
|
||||
settings.set("maxxy", maxxy)
|
||||
settings.set("clinex", 0)
|
||||
settings.set("cliney", 0)
|
||||
settings.set("prompt", ">>> ")
|
||||
#settings.set("clinex", 0)
|
||||
#settings.set("cliney", 0)
|
||||
|
||||
# Start loop in new thread
|
||||
thread = bt.needle.Needle(cline.loop.loop)
|
||||
|
@ -60,5 +61,5 @@ def close():
|
|||
|
||||
|
||||
# Called when the plugin needs to perform some action
|
||||
def run():
|
||||
def run(args=None):
|
||||
pass
|
||||
|
|
|
@ -2,4 +2,4 @@ __author__="bjschuma"
|
|||
__date__ ="$Dec 19, 2009 9:13:05 PM$"
|
||||
|
||||
|
||||
__all__ = ["addch", "loop"]
|
||||
__all__ = ["addch", "check", "loop", "message"]
|
|
@ -10,12 +10,36 @@ __date__ ="$Dec 19, 2009 11:19:43 PM$"
|
|||
import curses
|
||||
import settings
|
||||
|
||||
from run import run
|
||||
|
||||
# (Sometimes) add a character to the input string
|
||||
def addch(input):
|
||||
stdscr = settings.get("stdscr")
|
||||
c = stdscr.getch()
|
||||
|
||||
if(c >= 32 and c<= 126):
|
||||
if c == 10:
|
||||
enter(input)
|
||||
|
||||
elif c == 127:
|
||||
input = backspace(input)
|
||||
|
||||
elif(c >= 32 and c<= 126):
|
||||
input += curses.keyname(c)
|
||||
|
||||
return input
|
||||
return input
|
||||
|
||||
|
||||
|
||||
# Remove the last character in input
|
||||
def backspace(input):
|
||||
l = len(input)
|
||||
if(l>4):
|
||||
return input[:l-1]
|
||||
else:
|
||||
return input
|
||||
|
||||
|
||||
|
||||
# Attempt to run a command
|
||||
def enter(input):
|
||||
run(input)
|
|
@ -9,30 +9,31 @@ __date__ ="$Dec 19, 2009 9:39:37 PM$"
|
|||
|
||||
from bt.message import write
|
||||
import manager
|
||||
import settings
|
||||
|
||||
# Command line related imports
|
||||
from addch import addch
|
||||
from message import insert
|
||||
|
||||
|
||||
global halt
|
||||
halt = False
|
||||
|
||||
|
||||
# Loop around until the plugin manager calls shutdown
|
||||
def loop():
|
||||
write("Beginning command line loop",True)
|
||||
global halt
|
||||
|
||||
#stdscr = settings.get("stdscr")
|
||||
input = ""
|
||||
input = settings.get("prompt")
|
||||
(y, x) = settings.get("stdscr").getyx()
|
||||
insert(input, y)
|
||||
|
||||
while halt == False:
|
||||
input = addch(input)
|
||||
|
||||
#input=input[:x-4]+curses.keyname(c)+input[x-4:]
|
||||
#self.changeLine(y)
|
||||
#self.stdscr.move(y,x+1)
|
||||
if input == "exit":
|
||||
manager.manager.shutdown()
|
||||
halt = True
|
||||
#check(input)
|
||||
insert(input, y)
|
||||
|
||||
|
||||
def quit():
|
||||
|
|
|
@ -0,0 +1,15 @@
|
|||
#! /usr/bin/python
|
||||
|
||||
# To change this template, choose Tools | Templates
|
||||
# and open the template in the editor.
|
||||
|
||||
__author__="bjschuma"
|
||||
__date__ ="$Dec 19, 2009 11:57:19 PM$"
|
||||
|
||||
import settings
|
||||
|
||||
def insert(string, y):
|
||||
stdscr = settings.get("stdscr")
|
||||
|
||||
stdscr.deleteln()
|
||||
stdscr.addstr(y, 0, string)
|
|
@ -0,0 +1,19 @@
|
|||
#! /usr/bin/python
|
||||
|
||||
# To change this template, choose Tools | Templates
|
||||
# and open the template in the editor.
|
||||
|
||||
__author__="bjschuma"
|
||||
__date__ ="$Dec 19, 2009 11:38:46 PM$"
|
||||
|
||||
from manager import manager
|
||||
|
||||
|
||||
# Check for valid input
|
||||
def run(input):
|
||||
input = input[4:]
|
||||
split = input.split()
|
||||
if len(split)>1:
|
||||
manager.run(split[0],split[1:])
|
||||
else:
|
||||
manager.run(input)
|
|
@ -26,5 +26,5 @@ def close():
|
|||
|
||||
|
||||
# Called when the plugin needs to perform some action
|
||||
def run():
|
||||
def run(args=None):
|
||||
pass
|
||||
|
|
|
@ -0,0 +1,34 @@
|
|||
#! /usr/bin/python
|
||||
|
||||
# To change this template, choose Tools | Templates
|
||||
# and open the template in the editor.
|
||||
|
||||
__author__="bjschuma"
|
||||
__date__ ="$Dec 20, 2009 12:24:44 AM$"
|
||||
|
||||
|
||||
|
||||
global name, app, type, path, opt
|
||||
name = "exit"
|
||||
app = "scion"
|
||||
type = "core"
|
||||
path = ""
|
||||
opt = []
|
||||
|
||||
|
||||
from manager import manager
|
||||
|
||||
|
||||
# Called every time the plugin is enabled
|
||||
def open():
|
||||
pass
|
||||
|
||||
|
||||
# Called every time the plugin is stopped
|
||||
def close():
|
||||
pass
|
||||
|
||||
|
||||
# Called when the plugin needs to perform some action
|
||||
def run(args=None):
|
||||
manager.shutdown()
|
|
@ -0,0 +1,34 @@
|
|||
#! /usr/bin/python
|
||||
|
||||
# To change this template, choose Tools | Templates
|
||||
# and open the template in the editor.
|
||||
|
||||
__author__="bjschuma"
|
||||
__date__ ="$Dec 20, 2009 12:30:00 AM$"
|
||||
|
||||
|
||||
global name, app, type, path, opt
|
||||
name = "reload"
|
||||
app = "scion"
|
||||
type = "core"
|
||||
path = ""
|
||||
opt = []
|
||||
|
||||
|
||||
from manager import manager
|
||||
|
||||
|
||||
# Called every time the plugin is enabled
|
||||
def open():
|
||||
pass
|
||||
|
||||
|
||||
# Called every time the plugin is stopped
|
||||
def close():
|
||||
pass
|
||||
|
||||
|
||||
# Called when the plugin needs to perform some action
|
||||
def run(args=None):
|
||||
for plugin in args:
|
||||
manager.reloadPlugin(plugin)
|
Loading…
Reference in New Issue