From 7dad7e413c5c2ff98c846aeb7dd4f6cf955438e5 Mon Sep 17 00:00:00 2001 From: chrys Date: Wed, 14 Sep 2016 23:27:19 +0200 Subject: [PATCH] prepare for use etc as config --- src/fenrir-package/core/commandManager.py | 4 ++-- src/fenrir-package/core/screenManager.py | 8 +++---- src/fenrir-package/core/settingsManager.py | 25 +++++++++++----------- 3 files changed, 18 insertions(+), 19 deletions(-) diff --git a/src/fenrir-package/core/commandManager.py b/src/fenrir-package/core/commandManager.py index 488811f6..8743e919 100644 --- a/src/fenrir-package/core/commandManager.py +++ b/src/fenrir-package/core/commandManager.py @@ -49,8 +49,8 @@ class commandManager(): return environment def executeCommand(self, environment, currCommand, section = 'commands'): - if environment['generalInformation']['suspend']: - return environment + if environment['runtime']['screenManager'].isSuspendingScreen(environment) : + return environment if self.isCommandDefined(environment): try: environ = environment['commands'][section][currCommand].run(environment) diff --git a/src/fenrir-package/core/screenManager.py b/src/fenrir-package/core/screenManager.py index 1cb92600..e7eaaa98 100644 --- a/src/fenrir-package/core/screenManager.py +++ b/src/fenrir-package/core/screenManager.py @@ -4,18 +4,18 @@ from utils import debug class screenManager(): def __init__(self): - pass - def initialize(self, environment): self.autoIgnoreScreens = [] + + def initialize(self, environment): if environment['runtime']['settingsManager'].getSettingAsBool(environment,'screen', 'autodetectSuspendingScreen'): self.autoIgnoreScreens = environment['runtime']['screenDriver'].getIgnoreScreens() return environment + def shutdown(self, environment): return environment def update(self, environment): - environment['generalInformation']['suspend'] = self.isSuspendingScreen(environment) - if not environment['generalInformation']['suspend']: + if not self.isSuspendingScreen(environment): environment = environment['runtime']['screenDriver'].update(environment) environment['screenData']['lastScreenUpdate'] = time.time() return environment diff --git a/src/fenrir-package/core/settingsManager.py b/src/fenrir-package/core/settingsManager.py index 1b250437..8d7eb990 100644 --- a/src/fenrir-package/core/settingsManager.py +++ b/src/fenrir-package/core/settingsManager.py @@ -204,10 +204,12 @@ class settingsManager(): except: return '' - def initFenrirConfig(self): - return self.reInitFenrirConfig(environment.environment) - - def reInitFenrirConfig(self, environment, settingsRoot = '../../config/'): + def initFenrirConfig(self, environment = environment.environment, settingsRoot = '/etc/fenrir/config/'): + if not os.path.exists(settingsRoot): + if os.path.exists('../../config/'): + settingsRoot = '../../config/' + else: + return None environment['runtime']['settingsManager'] = self environment['runtime']['debug'] = debug.debug() environment = environment['runtime']['settingsManager'].loadSettings(environment) @@ -230,15 +232,12 @@ class settingsManager(): else: environment = environment['runtime']['settingsManager'].loadSoundIcons(environment, self.getSetting(environment, 'sound','theme')) - if environment['runtime']['inputManager'] == None: - environment['runtime']['inputManager'] = inputManager.inputManager() - environment = environment['runtime']['inputManager'].initialize(environment) - if environment['runtime']['outputManager'] == None: - environment['runtime']['outputManager'] = outputManager.outputManager() - environment = environment['runtime']['outputManager'].initialize(environment) - if environment['runtime']['commandManager'] == None: - environment['runtime']['commandManager'] = commandManager.commandManager() - environment = environment['runtime']['commandManager'].initialize(environment) + environment['runtime']['inputManager'] = inputManager.inputManager() + environment = environment['runtime']['inputManager'].initialize(environment) + environment['runtime']['outputManager'] = outputManager.outputManager() + environment = environment['runtime']['outputManager'].initialize(environment) + environment['runtime']['commandManager'] = commandManager.commandManager() + environment = environment['runtime']['commandManager'].initialize(environment) if environment['runtime']['screenManager'] == None: environment['runtime']['screenManager'] = screenManager.screenManager()