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 # Print an error message
def error(text): def error(text, trace):
lineno = str(inspect.currentframe().f_back.f_lineno) frame = trace[len(trace)-1]
filename = inspect.currentframe().f_back.f_code.co_filename filename = frame[1]
lineno = str(frame[2])
filename = filename.rsplit(os.sep,1)[1] filename = filename.rsplit(os.sep,1)[1]
write(filename+" ("+lineno+"): "+text) write(text + ": " + filename+" ("+lineno+")")
#settings.set("write", disp) #settings.set("write", disp)

View File

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

View File

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

View File

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

View File

@ -20,6 +20,7 @@ class Plugin(plugin.Plugin):
def __init__(self): def __init__(self):
plugin.Plugin.__init__(self) plugin.Plugin.__init__(self)
self.help = "The command line interface" self.help = "The command line interface"
self.usage = "cli [prompt]"
def open(self): def open(self):
@ -40,3 +41,10 @@ class Plugin(plugin.Plugin):
write("CLI has been stopped", True) write("CLI has been stopped", True)
settings.delete("keyinput") 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 # Set these values in settings class for use elsewhere
settings.set("stdscr", stdscr) settings.set("stdscr", stdscr)
settings.set("maxyx", maxyx) 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("clinex", 0)
settings.set("cliney", 0) settings.set("cliney", 0)
#settings.set("write", insert) #settings.set("write", insert)
@ -61,7 +64,7 @@ def quit():
# Delete keys that settings no longer needs # Delete keys that settings no longer needs
settings.delete("stdscr") settings.delete("stdscr")
settings.delete("maxyx") settings.delete("maxyx")
settings.delete("prompt") #settings.delete("prompt")
settings.delete("clinex") settings.delete("clinex")
settings.delete("cliney") settings.delete("cliney")
#settings.delete("everyloop") #settings.delete("everyloop")

View File

@ -13,8 +13,8 @@ from bt.message import write
# Check for valid input # Check for valid input
def run(input): def run(input):
prompt = input[0:4] prompt = settings.get("prompt")
input = input[4:].strip() input = input[len(prompt):].strip()
if len(input) == 0: if len(input) == 0:
return prompt return prompt
@ -25,5 +25,5 @@ def run(input):
else: else:
manager.run(input) manager.run(input)
# Account for the prompt changing when the manager runs
return prompt 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 sh ./clean.sh
TODAY=`date +%F` #TODAY=`date +%F`
SCION="scion-1.0-$TODAY" SCION="scion-1.1"
if [ ! -d "release" ]; if [ ! -d "release" ];
then then