Began reworking settings and sessions

This commit is contained in:
bjschuma 2010-02-17 22:22:43 -05:00
parent 551764de64
commit 2bf15d4161
6 changed files with 73 additions and 16 deletions

View File

@ -2,4 +2,4 @@
# It contains various tools needed by the base layer of ocarina2
__all__ = ["alias", "file", "map", "message", "needle", "plugin", "proc",
"scripting", "signal", "sql", "xm"]
"scripting", "settings", "signal", "sql", "xm"]

View File

@ -5,7 +5,7 @@ __date__ ="$Dec 5, 2009 6:46:13 PM$"
import os
import inspect
import settings
from session import session
import bt.signal
global enabled
@ -31,7 +31,7 @@ def write(text,verbose=False):
global enabled
if enabled == False:
return
if (verbose==False) or (settings.get("verbose")==True):
if (verbose==False) or (session.settings["verbose"]==True):
bt.signal.emit("message-write",str(text))

View File

@ -3,7 +3,7 @@
__author__="bjschuma"
__date__ ="$Dec 5, 2009 6:33:50 PM$"
import settings
from session import session
from message import write
# Set our process name to name
@ -11,7 +11,7 @@ def setname(name):
# Set the process name (thank you exaile.py)
# This only works on linux2 machines
message = "Attempting to set process name to " + name + "..."
if settings.settings["ARCH"] == 'linux2':
if session.settings["ARCH"] == 'linux2':
try:
import ctypes
libc = ctypes.CDLL('libc.so.6')

37
src/core/bt/settings.py Normal file
View File

@ -0,0 +1,37 @@
#! /usr/bin/python
# To change this template, choose Tools | Templates
# and open the template in the editor.
__author__="bjschuma"
__date__ ="$Feb 17, 2010 9:32:56 PM$"
class Settings(dict):
def __init__(self):
dict.__init__(self)
def has(self,key):
return (key.upper() in self)
def init(self,key,value):
if self.has(key)==False:
self[key] = value
def __setitem__(self,key,value):
key = key.upper()
dict.__setitem__(self,key,value)
def __getitem__(self,key):
key = key.upper()
if self.has(key)==True:
return dict.__getitem__(self,key)
return None
def __delitem__(self,key):
dict.__delitem__(self,key.upper())

View File

@ -5,8 +5,8 @@ __author__="bjschuma"
__date__ ="$Dec 4, 2009 3:37:21 PM$"
# We need to import settings before we can use disp()
import settings
settings.set("appname","scion")
from session import session
session.settings["appname"] = "scion"
# The first thing we do is import write() so we can occasionally print messages
from bt.message import write
@ -17,8 +17,8 @@ from bt.signal import emit
from bt.file import join
# Import the plugin loader class!
import loader
import manager
#import loader
#import manager
def loadPluginPath(path):
@ -28,19 +28,19 @@ def loadPluginPath(path):
# Begin our main loop
def main():
for path in settings.get("PLUGPATH"):
loadPluginPath(path)
#for path in session.settings.get("PLUGPATH"):
# loadPluginPath(path)
emit("scion-plugins-loaded")
app = settings.get("appname")
app = session.settings["appname"]
write("Welcome to "+app+"!")
setname(app)
settings.set("appdir", join(settings.get("user"), "."+app) )
#session.settings["appdir"] = join(session.settings["user"], "."+app)
manager.manager.restoresession()
manager.manager.startup()
emit("scion-begin")
#manager.manager.restoresession()
#manager.manager.startup()
#emit("scion-begin")
#settings.get("loop")()

20
src/core/session.py Normal file
View File

@ -0,0 +1,20 @@
#! /usr/bin/python
# To change this template, choose Tools | Templates
# and open the template in the editor.
__author__="bjschuma"
__date__ ="$Feb 17, 2010 9:18:50 PM$"
from bt.settings import Settings
class Session():
def __init__(self):
self.settings = Settings()
global session
session = Session()