From 045539bb4624ae5cd7365faa74f8481884a44655 Mon Sep 17 00:00:00 2001 From: chrys Date: Fri, 30 Jun 2017 22:07:56 +0200 Subject: [PATCH] add debug flag --- src/fenrir/core/fenrirManager.py | 4 ++-- src/fenrir/core/settingsManager.py | 27 +++++++++++++++++---------- 2 files changed, 19 insertions(+), 12 deletions(-) diff --git a/src/fenrir/core/fenrirManager.py b/src/fenrir/core/fenrirManager.py index 0d4f3ab2..8ea01b67 100644 --- a/src/fenrir/core/fenrirManager.py +++ b/src/fenrir/core/fenrirManager.py @@ -37,7 +37,8 @@ class fenrirManager(): args = None parser = argparse.ArgumentParser(description="Fenrir Help") parser.add_argument('-s', '--setting', metavar='SETTING-FILE', default='/etc/fenrir/settings/settings.conf', help='Use a specified settingsfile') - parser.add_argument('-o', '--options', metavar='SECTION#SETTING=VALUE,..', default='', help='Overwrite options in given settings file') + parser.add_argument('-o', '--options', metavar='SECTION#SETTING=VALUE,..', default='', help='Overwrite options in given settings file') + parser.add_argument('-d', '--debug', const=True, default='', nargs='?', help='Turns on Debugmode') try: args = parser.parse_args() except Exception as e: @@ -54,7 +55,6 @@ class fenrirManager(): if eventReceived: self.prepareCommand() if not (self.wasCommand or self.environment['general']['tutorialMode']) or self.environment['runtime']['screenManager'].isSuspendingScreen(): - print('ignore screen', self.environment['runtime']['screenManager'].isSuspendingScreen()) self.environment['runtime']['inputManager'].writeEventBuffer() if self.environment['runtime']['inputManager'].noKeyPressed(): if self.wasCommand: diff --git a/src/fenrir/core/settingsManager.py b/src/fenrir/core/settingsManager.py index 069a8564..df0e65c4 100644 --- a/src/fenrir/core/settingsManager.py +++ b/src/fenrir/core/settingsManager.py @@ -226,8 +226,16 @@ class settingsManager(): for key in keyList: if not key in self.env['input']['scriptKey']: self.env['input']['scriptKey'].append(key) + def setOptionArgDict(self, section, option, value): + section = section.lower() + option = option.lower() + try: + e = self.settingArgDict[section] + except KeyError: + self.settingArgDict[section] = {} + self.settingArgDict[section][option] = str(value) + def parseSettingArgs(self, settingArgs): - optionArgDict = {} for optionElem in settingArgs.split(';'): if len(optionElem.split('#',1)) != 2: continue @@ -236,13 +244,8 @@ class settingsManager(): section = str(optionElem.split('#',1)[0]).lower() option = str(optionElem.split('#',1)[1].split('=',1)[0]).lower() value = optionElem.split('#',1)[1].split('=',1)[1] - try: - e = optionArgDict[section] - except KeyError: - optionArgDict[section] = {} - optionArgDict[section][option] = str(value) - print(optionArgDict) - return optionArgDict + self.setOptionArgDict(section, option, value) + def initFenrirConfig(self, cliArgs, fenrirManager = None, environment = environment.environment): settingsRoot = '/etc/fenrir/' settingsFile = cliArgs.setting @@ -272,11 +275,15 @@ class settingsManager(): validConfig = environment['runtime']['settingsManager'].loadSettings(settingsFile) if not validConfig: return None + if cliArgs.options != '': - self.settingArgDict = self.parseSettingArgs(cliArgs.options) + self.parseSettingArgs(cliArgs.options) + if cliArgs.debug: + self.setOptionArgDict('general', 'debugLevel', 3) + self.setFenrirKeys(self.getSetting('general','fenrirKeys')) self.setScriptKeys(self.getSetting('general','scriptKeys')) - + if not os.path.exists(self.getSetting('keyboard','keyboardLayout')): if os.path.exists(settingsRoot + 'keyboard/' + self.getSetting('keyboard','keyboardLayout')): self.setSetting('keyboard', 'keyboardLayout', settingsRoot + 'keyboard/' + self.getSetting('keyboard','keyboardLayout'))