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 # It contains various tools needed by the base layer of ocarina2
__all__ = ["alias", "file", "map", "message", "needle", "plugin", "proc", __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 os
import inspect import inspect
import settings from session import session
import bt.signal import bt.signal
global enabled global enabled
@ -31,7 +31,7 @@ def write(text,verbose=False):
global enabled global enabled
if enabled == False: if enabled == False:
return return
if (verbose==False) or (settings.get("verbose")==True): if (verbose==False) or (session.settings["verbose"]==True):
bt.signal.emit("message-write",str(text)) bt.signal.emit("message-write",str(text))

View File

@ -3,7 +3,7 @@
__author__="bjschuma" __author__="bjschuma"
__date__ ="$Dec 5, 2009 6:33:50 PM$" __date__ ="$Dec 5, 2009 6:33:50 PM$"
import settings from session import session
from message import write from message import write
# Set our process name to name # Set our process name to name
@ -11,7 +11,7 @@ def setname(name):
# Set the process name (thank you exaile.py) # Set the process name (thank you exaile.py)
# This only works on linux2 machines # This only works on linux2 machines
message = "Attempting to set process name to " + name + "..." message = "Attempting to set process name to " + name + "..."
if settings.settings["ARCH"] == 'linux2': if session.settings["ARCH"] == 'linux2':
try: try:
import ctypes import ctypes
libc = ctypes.CDLL('libc.so.6') 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$" __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()
import settings from session import session
settings.set("appname","scion") 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 +17,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,19 +28,19 @@ def loadPluginPath(path):
# Begin our main loop # Begin our main loop
def main(): def main():
for path in settings.get("PLUGPATH"): #for path in session.settings.get("PLUGPATH"):
loadPluginPath(path) # loadPluginPath(path)
emit("scion-plugins-loaded") emit("scion-plugins-loaded")
app = settings.get("appname") app = session.settings["appname"]
write("Welcome to "+app+"!") write("Welcome to "+app+"!")
setname(app) setname(app)
settings.set("appdir", join(settings.get("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")() #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()