From 9befaf7c91218ae0d31d90291e2ef5162d0deb79 Mon Sep 17 00:00:00 2001 From: blitzman Date: Sun, 5 Mar 2017 01:53:19 -0500 Subject: [PATCH] Test implementation of eos settings --- config.py | 4 ++++ eos/config.py | 4 ++++ eos/effects/tractorbeamcan.py | 3 ++- service/settings.py | 20 ++++++++++++++++++++ 4 files changed, 30 insertions(+), 1 deletion(-) diff --git a/config.py b/config.py index 447e81763..e3bfad025 100644 --- a/config.py +++ b/config.py @@ -105,3 +105,7 @@ def defPaths(customSavePath): # saveddata db location modifier, shouldn't ever need to touch this eos.config.saveddata_connectionstring = "sqlite:///" + saveDB + "?check_same_thread=False" eos.config.gamedata_connectionstring = "sqlite:///" + gameDB + "?check_same_thread=False" + + # initialize the settings + from service.settings import EOSSettings + eos.config.settings = EOSSettings.getInstance().EOSSettings # this is kind of confusing, but whatever diff --git a/eos/config.py b/eos/config.py index 01d65cfe0..cf5b2e937 100644 --- a/eos/config.py +++ b/eos/config.py @@ -10,6 +10,10 @@ gamedata_connectionstring = 'sqlite:///' + unicode(realpath(join(dirname(abspath saveddata_connectionstring = 'sqlite:///' + unicode( realpath(join(dirname(abspath(__file__)), "..", "saveddata", "saveddata.db")), sys.getfilesystemencoding()) +settings = { + "setting1": True +} # Autodetect path, only change if the autodetection bugs out. path = dirname(unicode(__file__, sys.getfilesystemencoding())) + diff --git a/eos/effects/tractorbeamcan.py b/eos/effects/tractorbeamcan.py index 293a839ea..c865b1c22 100644 --- a/eos/effects/tractorbeamcan.py +++ b/eos/effects/tractorbeamcan.py @@ -3,7 +3,8 @@ # Used by: # Modules from group: Tractor Beam (4 of 4) type = "active" - +from eos.config import settings def handler(fit, module, context): + print settings['setting1'] pass diff --git a/service/settings.py b/service/settings.py index f3d6a9376..0159bc516 100644 --- a/service/settings.py +++ b/service/settings.py @@ -22,6 +22,7 @@ import os.path import urllib2 import config +import eos.config from logbook import Logger pyfalog = Logger(__name__) @@ -436,4 +437,23 @@ class ContextMenuSettings(object): def set(self, type, value): self.ContextMenuDefaultSettings[type] = value +class EOSSettings(object): + _instance = None + + @classmethod + def getInstance(cls): + if cls._instance is None: + cls._instance = EOSSettings() + + return cls._instance + + def __init__(self): + self.EOSSettings = SettingsProvider.getInstance().getSettings("pyfaEOSSettings", eos.config.settings) + + def get(self, type): + return self.EOSSettings[type] + + def set(self, type, value): + self.EOSSettings[type] = value + # @todo: migrate fit settings (from fit service) here?