mirror of
https://github.com/MCV-Software/TWBlue.git
synced 2025-07-21 07:16:07 -04:00
The next generation branch has been added
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
# -*- coding: cp1252 -*-
|
||||
from config_utils import Configuration, ConfigurationResetException
|
||||
#from config_utils import Configuration, ConfigurationResetException
|
||||
import config
|
||||
import paths
|
||||
import os
|
||||
import session_exceptions
|
||||
@@ -10,17 +11,17 @@ def setup():
|
||||
manager = sessionManager()
|
||||
|
||||
class sessionManager(object):
|
||||
def __init__(self):
|
||||
FILE = "sessions.conf"
|
||||
SPEC = "sessions.defaults"
|
||||
try:
|
||||
self.main = Configuration(paths.config_path(FILE), paths.app_path(SPEC))
|
||||
except ConfigurationResetException:
|
||||
pass
|
||||
# def __init__(self):
|
||||
# FILE = "sessions.conf"
|
||||
# SPEC = "app-configuration.defaults"
|
||||
# try:
|
||||
# self.main = Configuration(paths.config_path(FILE), paths.app_path(SPEC))
|
||||
# except ConfigurationResetException:
|
||||
# pass
|
||||
|
||||
def get_current_session(self):
|
||||
if self.is_valid(self.main["sessions"]["current_session"]):
|
||||
return self.main["sessions"]["current_session"]
|
||||
if self.is_valid(config.app["sessions"]["current_session"]):
|
||||
return config.app["sessions"]["current_session"]
|
||||
else:
|
||||
return False
|
||||
|
||||
@@ -28,16 +29,16 @@ class sessionManager(object):
|
||||
path = paths.config_path(id)
|
||||
if not os.path.exists(path):
|
||||
os.mkdir(path)
|
||||
self.main["sessions"]["sessions"].append(id)
|
||||
config.app["sessions"]["sessions"].append(id)
|
||||
|
||||
def set_current_session(self, sessionID):
|
||||
self.main["sessions"]["current_session"] = sessionID
|
||||
self.main.write()
|
||||
config.app["sessions"]["current_session"] = sessionID
|
||||
config.app.write()
|
||||
|
||||
def is_valid(self, id):
|
||||
if not os.path.exists(paths.config_path(id)):
|
||||
raise session_exceptions.NonExistentSessionError("That session does not exist.")
|
||||
self.main["sessions"]["current_session"] = ""
|
||||
config.app["sessions"]["current_session"] = ""
|
||||
return False
|
||||
else:
|
||||
return True
|
Reference in New Issue
Block a user