Continued work with reworking startup / sessions
This commit is contained in:
parent
2bf15d4161
commit
6b7347464a
|
@ -4,8 +4,9 @@ __author__="bjschuma"
|
||||||
__date__ ="$Dec 5, 2009 6:46:13 PM$"
|
__date__ ="$Dec 5, 2009 6:46:13 PM$"
|
||||||
|
|
||||||
import os
|
import os
|
||||||
import inspect
|
#import inspect
|
||||||
from session import session
|
#from session import session
|
||||||
|
import session
|
||||||
import bt.signal
|
import bt.signal
|
||||||
|
|
||||||
global enabled
|
global enabled
|
||||||
|
@ -27,11 +28,11 @@ def disp(text):
|
||||||
|
|
||||||
|
|
||||||
# Print general text to the screen
|
# Print general text to the screen
|
||||||
def write(text,verbose=False):
|
def write(text,verbose=0):
|
||||||
global enabled
|
global enabled
|
||||||
if enabled == False:
|
if enabled == False:
|
||||||
return
|
return
|
||||||
if (verbose==False) or (session.settings["verbose"]==True):
|
if (verbose <= session.settings["verbose"]):
|
||||||
bt.signal.emit("message-write",str(text))
|
bt.signal.emit("message-write",str(text))
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
__author__="bjschuma"
|
__author__="bjschuma"
|
||||||
__date__ ="$Dec 5, 2009 6:33:50 PM$"
|
__date__ ="$Dec 5, 2009 6:33:50 PM$"
|
||||||
|
|
||||||
from session import session
|
import session
|
||||||
from message import write
|
from message import write
|
||||||
|
|
||||||
# Set our process name to name
|
# Set our process name to name
|
||||||
|
|
|
@ -6,12 +6,31 @@
|
||||||
__author__="bjschuma"
|
__author__="bjschuma"
|
||||||
__date__ ="$Feb 17, 2010 9:32:56 PM$"
|
__date__ ="$Feb 17, 2010 9:32:56 PM$"
|
||||||
|
|
||||||
|
from sys import argv,platform
|
||||||
|
import os
|
||||||
|
|
||||||
|
from bt.message import write
|
||||||
|
|
||||||
|
|
||||||
class Settings(dict):
|
class Settings(dict):
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
dict.__init__(self)
|
dict.__init__(self)
|
||||||
|
|
||||||
|
|
||||||
|
def setdefaults(self):
|
||||||
|
count = 0
|
||||||
|
if ("-v" in argv) or ("--verbose" in argv):
|
||||||
|
count = argv.count("-v") + argv.count("--verbose")
|
||||||
|
self['verbose'] = count
|
||||||
|
write("Setting default values",1)
|
||||||
|
self['user'] = os.path.expanduser("~")
|
||||||
|
self['plugpath'] = ["plugins", "extra"]
|
||||||
|
self['arch'] = platform
|
||||||
|
self['appname'] = "scion"
|
||||||
|
write(self,3)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def has(self,key):
|
def has(self,key):
|
||||||
return (key.upper() in self)
|
return (key.upper() in self)
|
||||||
|
|
||||||
|
@ -35,3 +54,7 @@ class Settings(dict):
|
||||||
|
|
||||||
def __delitem__(self,key):
|
def __delitem__(self,key):
|
||||||
dict.__delitem__(self,key.upper())
|
dict.__delitem__(self,key.upper())
|
||||||
|
|
||||||
|
|
||||||
|
def load(self,path):
|
||||||
|
pass
|
||||||
|
|
|
@ -9,7 +9,7 @@ from bt.signal import *
|
||||||
from bt import alias
|
from bt import alias
|
||||||
#import loader
|
#import loader
|
||||||
|
|
||||||
import settings
|
import session
|
||||||
|
|
||||||
import inspect
|
import inspect
|
||||||
|
|
||||||
|
@ -123,15 +123,15 @@ class Manager:
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
|
||||||
def findsession(self):
|
#def findsession(self):
|
||||||
path = settings.get("user")
|
# path = session.session.settings.get("user")
|
||||||
if path == expandPath("~"):
|
# if path == expandPath("~"):
|
||||||
#path = join(path,".scion")
|
# #path = join(path,".scion")
|
||||||
path = join(path,"."+settings.get("appname"))
|
# path = join(path,"."+settings.get("appname"))
|
||||||
mkdir(path)
|
# mkdir(path)
|
||||||
path = join(path,"session")
|
# path = join(path,"session")
|
||||||
mkdir(path)
|
# mkdir(path)
|
||||||
return path
|
# return path
|
||||||
|
|
||||||
|
|
||||||
def savesession(self,session):
|
def savesession(self,session):
|
||||||
|
@ -143,8 +143,8 @@ class Manager:
|
||||||
|
|
||||||
|
|
||||||
def restoresession(self):
|
def restoresession(self):
|
||||||
path = self.findsession()
|
path = session.getSession()
|
||||||
settings.load(path)
|
session.settings.load(path)
|
||||||
path = join(path,"enabled")
|
path = join(path,"enabled")
|
||||||
file = fopen(path)
|
file = fopen(path)
|
||||||
self.restored = []
|
self.restored = []
|
||||||
|
|
|
@ -5,8 +5,7 @@ __author__="bjschuma"
|
||||||
__date__ ="$Dec 4, 2009 3:37:21 PM$"
|
__date__ ="$Dec 4, 2009 3:37:21 PM$"
|
||||||
|
|
||||||
# We need to import settings before we can use disp()
|
# We need to import settings before we can use disp()
|
||||||
from session import session
|
import session
|
||||||
session.settings["appname"] = "scion"
|
|
||||||
|
|
||||||
# The first thing we do is import write() so we can occasionally print messages
|
# The first thing we do is import write() so we can occasionally print messages
|
||||||
from bt.message import write
|
from bt.message import write
|
||||||
|
@ -17,8 +16,8 @@ from bt.signal import emit
|
||||||
from bt.file import join
|
from bt.file import join
|
||||||
|
|
||||||
# Import the plugin loader class!
|
# Import the plugin loader class!
|
||||||
#import loader
|
import loader
|
||||||
#import manager
|
import manager
|
||||||
|
|
||||||
|
|
||||||
def loadPluginPath(path):
|
def loadPluginPath(path):
|
||||||
|
@ -28,20 +27,19 @@ def loadPluginPath(path):
|
||||||
|
|
||||||
# Begin our main loop
|
# Begin our main loop
|
||||||
def main():
|
def main():
|
||||||
#for path in session.settings.get("PLUGPATH"):
|
for path in session.settings.get("PLUGPATH"):
|
||||||
# loadPluginPath(path)
|
loadPluginPath(path)
|
||||||
|
|
||||||
emit("scion-plugins-loaded")
|
emit("scion-plugins-loaded")
|
||||||
|
|
||||||
app = session.settings["appname"]
|
app = session.settings["appname"]
|
||||||
write("Welcome to "+app+"!")
|
write("Welcome to "+app+"!")
|
||||||
setname(app)
|
setname(app)
|
||||||
#session.settings["appdir"] = join(session.settings["user"], "."+app)
|
session.settings["appdir"] = join(session.settings["user"], "."+app)
|
||||||
|
|
||||||
#manager.manager.restoresession()
|
manager.manager.restoresession()
|
||||||
#manager.manager.startup()
|
manager.manager.startup()
|
||||||
#emit("scion-begin")
|
#emit("scion-begin")
|
||||||
#settings.get("loop")()
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -8,13 +8,20 @@ __date__ ="$Feb 17, 2010 9:18:50 PM$"
|
||||||
|
|
||||||
|
|
||||||
from bt.settings import Settings
|
from bt.settings import Settings
|
||||||
|
from bt.file import *
|
||||||
|
global settings
|
||||||
|
|
||||||
class Session():
|
|
||||||
def __init__(self):
|
def getSession():
|
||||||
self.settings = Settings()
|
path = settings["user"]
|
||||||
|
if path == expandPath("~"):
|
||||||
|
path = join(path,"."+settings["appname"])
|
||||||
|
mkdir(path)
|
||||||
|
path = join(path,"session")
|
||||||
|
mkdir(path)
|
||||||
|
return path
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
global session
|
settings = Settings()
|
||||||
session = Session()
|
settings.setdefaults()
|
||||||
|
|
|
@ -13,6 +13,8 @@ import cline.loop
|
||||||
import cline.addch
|
import cline.addch
|
||||||
import cline.message
|
import cline.message
|
||||||
import cline.history
|
import cline.history
|
||||||
|
|
||||||
|
from session import settings
|
||||||
#import settings
|
#import settings
|
||||||
|
|
||||||
|
|
||||||
|
@ -33,18 +35,18 @@ class Plugin(plugin.Plugin):
|
||||||
register("scion-end", cline.loop.quit)
|
register("scion-end", cline.loop.quit)
|
||||||
|
|
||||||
# Initialize a dictionary for key press inputs
|
# Initialize a dictionary for key press inputs
|
||||||
settings.set("keyinput", dict())
|
settings["keyinput"] = dict()
|
||||||
settings.get("keyinput")[259] = cline.history.prev
|
settings["keyinput"][259] = cline.history.prev
|
||||||
settings.get("keyinput")[258] = cline.history.next
|
settings["keyinput"][258] = cline.history.next
|
||||||
settings.get("keyinput")[127] = cline.addch.backspace
|
settings["keyinput"][127] = cline.addch.backspace
|
||||||
settings.get("keyinput")[10] = cline.addch.enter
|
settings["keyinput"][10] = cline.addch.enter
|
||||||
|
|
||||||
|
|
||||||
def close(self):
|
def close(self):
|
||||||
cline.loop.quit()
|
cline.loop.quit()
|
||||||
cline.history.save()
|
cline.history.save()
|
||||||
write("CLI has been stopped", True)
|
write("CLI has been stopped", True)
|
||||||
settings.delete("keyinput")
|
del settings["keyinput"]
|
||||||
remove("scion-begin",cline.loop.loop)
|
remove("scion-begin",cline.loop.loop)
|
||||||
remove("scion-end",cline.loop.quit)
|
remove("scion-end",cline.loop.quit)
|
||||||
|
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
__author__="bjschuma"
|
__author__="bjschuma"
|
||||||
__date__ ="$Jan 29, 2010 9:59:20 AM$"
|
__date__ ="$Jan 29, 2010 9:59:20 AM$"
|
||||||
|
|
||||||
import settings
|
from session import settings
|
||||||
from bt.file import *
|
from bt.file import *
|
||||||
|
|
||||||
global hist
|
global hist
|
||||||
|
@ -29,7 +29,7 @@ def insert(input):
|
||||||
|
|
||||||
|
|
||||||
def getfile(flags='r'):
|
def getfile(flags='r'):
|
||||||
dir = settings.get("appdir")
|
dir = settings["appdir"]
|
||||||
file = join(dir,"history")
|
file = join(dir,"history")
|
||||||
return fopen(file,flags)
|
return fopen(file,flags)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue