Can change CLI prompt whenever, changed how bt.message.error() gets info

This commit is contained in:
bjschuma 2010-01-29 00:38:41 -05:00
parent 9bcf1dcf64
commit b6ec04cc9a
9 changed files with 42 additions and 17 deletions

View File

@ -41,11 +41,12 @@ def write(text,verbose=False):
# Print an error message
def error(text):
lineno = str(inspect.currentframe().f_back.f_lineno)
filename = inspect.currentframe().f_back.f_code.co_filename
def error(text, trace):
frame = trace[len(trace)-1]
filename = frame[1]
lineno = str(frame[2])
filename = filename.rsplit(os.sep,1)[1]
write(filename+" ("+lineno+"): "+text)
write(text + ": " + filename+" ("+lineno+")")
#settings.set("write", disp)

View File

@ -1,3 +1,4 @@
import os.path
#! /usr/bin/python
# To change this template, choose Tools | Templates
@ -12,11 +13,14 @@ import settings
from bt.file import *
def getdb():
return join(settings.get("appdir"), settings.get("appname")+".db")
def dbexists():
return checkPath(getdb())
def connect():
path = getdb()
con = sqlite3.connect(path)
@ -109,5 +113,6 @@ class Insert(Statement):
qs+="?"
self.statement+=qs + ")"
#write(self.statement)
#write(self.values)
Statement.execute(self, self.values)

View File

@ -8,9 +8,12 @@ from bt.message import *
from bt.file import *
from bt.signal import *
from bt import alias
import loader
#import loader
import settings
import inspect
class Manager:
def __init__(self):
write("Creating plugin manager", True)
@ -56,7 +59,7 @@ class Manager:
plugin.open()
return True
except:
error("Error enabling: "+name)
error("Error enabling: "+name, inspect.trace())
return False
@ -124,7 +127,8 @@ class Manager:
def findsession(self):
path = settings.get("user")
if path == expandPath("~"):
path = join(path,".scion")
#path = join(path,".scion")
path = join(path,"."+settings.get("appname"))
mkdir(path)
path = join(path,"session")
mkdir(path)

View File

@ -65,7 +65,8 @@ def parseInput():
opts, args = getopt.getopt(input, optc, long)
for opt in opts:
if opt[0] == "-p":
set("PLUGPATH", opt[1], True)
set("plugpath",get("plugpath")+[opt[1]])
#set("PLUGPATH", opt[1])
set("ARGS", args)
except getopt.GetoptError, e:
error(e.msg)
@ -73,6 +74,7 @@ def parseInput():
def clean():
delete("appdir")
delete("appname")
delete("arch")
delete("args")

View File

@ -20,6 +20,7 @@ class Plugin(plugin.Plugin):
def __init__(self):
plugin.Plugin.__init__(self)
self.help = "The command line interface"
self.usage = "cli [prompt]"
def open(self):
@ -40,3 +41,10 @@ class Plugin(plugin.Plugin):
write("CLI has been stopped", True)
settings.delete("keyinput")
def run(self,args):
if args==None or len(args)<2:
write(self.usage)
if args[0]=="prompt":
settings.set("prompt",args[1]+" ")

View File

@ -34,7 +34,10 @@ def init():
# Set these values in settings class for use elsewhere
settings.set("stdscr", stdscr)
settings.set("maxyx", maxyx)
settings.set("prompt", ">>> ")
if settings.has("prompt") == False:
settings.set("prompt", ">>> ")
else:
settings.set("prompt",settings.get("prompt")+" ")
settings.set("clinex", 0)
settings.set("cliney", 0)
#settings.set("write", insert)
@ -61,7 +64,7 @@ def quit():
# Delete keys that settings no longer needs
settings.delete("stdscr")
settings.delete("maxyx")
settings.delete("prompt")
#settings.delete("prompt")
settings.delete("clinex")
settings.delete("cliney")
#settings.delete("everyloop")

View File

@ -13,8 +13,8 @@ from bt.message import write
# Check for valid input
def run(input):
prompt = input[0:4]
input = input[4:].strip()
prompt = settings.get("prompt")
input = input[len(prompt):].strip()
if len(input) == 0:
return prompt
@ -25,5 +25,5 @@ def run(input):
else:
manager.run(input)
return prompt
# Account for the prompt changing when the manager runs
return settings.get("prompt")

2
src/count.sh Normal file
View File

@ -0,0 +1,2 @@
cat base/*.py base/bt/*.py core/*.py core/cline/*.py extra/*.py extra/guiGTK/*.py | grep -v [[:space:]]*# | cat -b

View File

@ -2,8 +2,8 @@
sh ./clean.sh
TODAY=`date +%F`
SCION="scion-1.0-$TODAY"
#TODAY=`date +%F`
SCION="scion-1.1"
if [ ! -d "release" ];
then