check datatypes
This commit is contained in:
parent
93bf3fb1df
commit
e456ffc5a2
@ -103,7 +103,7 @@ class settingsManager():
|
|||||||
def getSetting(self, section, setting):
|
def getSetting(self, section, setting):
|
||||||
value = ''
|
value = ''
|
||||||
try:
|
try:
|
||||||
value = self.settingArgDict[section.lower()][setting.lower()]
|
value = self.settingArgDict[section][setting]
|
||||||
return value
|
return value
|
||||||
except:
|
except:
|
||||||
pass
|
pass
|
||||||
@ -116,7 +116,7 @@ class settingsManager():
|
|||||||
def getSettingAsInt(self, section, setting):
|
def getSettingAsInt(self, section, setting):
|
||||||
value = 0
|
value = 0
|
||||||
try:
|
try:
|
||||||
value = int(self.settingArgDict[section.lower()][setting.lower()])
|
value = int(self.settingArgDict[section][setting])
|
||||||
return value
|
return value
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
pass
|
pass
|
||||||
@ -129,7 +129,7 @@ class settingsManager():
|
|||||||
def getSettingAsFloat(self, section, setting):
|
def getSettingAsFloat(self, section, setting):
|
||||||
value = 0.0
|
value = 0.0
|
||||||
try:
|
try:
|
||||||
value = float(self.settingArgDict[section.lower()][setting.lower()])
|
value = float(self.settingArgDict[section][setting])
|
||||||
return value
|
return value
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
pass
|
pass
|
||||||
@ -142,7 +142,7 @@ class settingsManager():
|
|||||||
def getSettingAsBool(self, section, setting):
|
def getSettingAsBool(self, section, setting):
|
||||||
value = False
|
value = False
|
||||||
try:
|
try:
|
||||||
value = self.settingArgDict[section.lower()][setting.lower()].upper() in ['1','YES','JA','TRUE']
|
value = self.settingArgDict[section][setting].upper() in ['1','YES','JA','TRUE']
|
||||||
return value
|
return value
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
pass
|
pass
|
||||||
@ -194,14 +194,35 @@ class settingsManager():
|
|||||||
self.env['input']['scriptKey'].append(key)
|
self.env['input']['scriptKey'].append(key)
|
||||||
def resetSettingArgDict(self):
|
def resetSettingArgDict(self):
|
||||||
self.settingArgDict = {}
|
self.settingArgDict = {}
|
||||||
def setOptionArgDict(self, section, option, value):
|
def setOptionArgDict(self, section, setting, value):
|
||||||
section = section.lower()
|
#section = section.lower()
|
||||||
option = option.lower()
|
#setting = setting.lower()
|
||||||
try:
|
try:
|
||||||
e = self.settingArgDict[section]
|
e = self.settingArgDict[section]
|
||||||
except KeyError:
|
except KeyError:
|
||||||
self.settingArgDict[section] = {}
|
self.settingArgDict[section] = {}
|
||||||
self.settingArgDict[section][option] = str(value)
|
try:
|
||||||
|
t = self.settings[section][setting]
|
||||||
|
except:
|
||||||
|
print(section,setting, 'not found')
|
||||||
|
return
|
||||||
|
try:
|
||||||
|
if isinstance(self.settings[section][setting], str):
|
||||||
|
v = str(value)
|
||||||
|
elif isinstance(self.settings[section][setting], bool):
|
||||||
|
if not value in ['True','False']:
|
||||||
|
raise ValueError('could not convert string to bool: '+ value)
|
||||||
|
elif isinstance(self.settings[section][setting], int):
|
||||||
|
v = int(value)
|
||||||
|
elif isinstance(self.settings[section][setting], float):
|
||||||
|
v = float(value)
|
||||||
|
self.settingArgDict[section][setting] = str(value)
|
||||||
|
except Exception as e:
|
||||||
|
print('settingsManager:setOptionArgDict:Datatype missmatch: '+ section + '#' + setting + '=' + value + ' Error:' + str(e))
|
||||||
|
#self.env['runtime']['debug'].writeDebugOut('settingsManager:setOptionArgDict:Datatype missmatch: '+ section + '#' + setting + '=' + value + ' Error:' + str(e), debug.debugLevel.ERROR)
|
||||||
|
return
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def parseSettingArgs(self, settingArgs):
|
def parseSettingArgs(self, settingArgs):
|
||||||
for optionElem in settingArgs.split(';'):
|
for optionElem in settingArgs.split(';'):
|
||||||
@ -245,20 +266,20 @@ class settingsManager():
|
|||||||
if cliArgs.options != '':
|
if cliArgs.options != '':
|
||||||
self.parseSettingArgs(cliArgs.options)
|
self.parseSettingArgs(cliArgs.options)
|
||||||
if cliArgs.debug:
|
if cliArgs.debug:
|
||||||
self.setOptionArgDict('general', 'debugLevel', 3)
|
self.setSetting('general', 'debugLevel', 3)
|
||||||
if cliArgs.print:
|
if cliArgs.print:
|
||||||
self.setOptionArgDict('general', 'debugLevel', 3)
|
self.setSetting('general', 'debugLevel', 3)
|
||||||
self.setOptionArgDict('general', 'debugMode', 'PRINT')
|
self.setSetting('general', 'debugMode', 'PRINT')
|
||||||
if cliArgs.emulated_pty:
|
if cliArgs.emulated_pty:
|
||||||
self.setOptionArgDict('screen', 'driver', 'ptyDriver')
|
self.setSetting('screen', 'driver', 'ptyDriver')
|
||||||
self.setOptionArgDict('keyboard', 'driver', 'ptyDriver')
|
self.setSetting('keyboard', 'driver', 'ptyDriver')
|
||||||
# TODO needs cleanup use dict
|
# TODO needs cleanup use dict
|
||||||
#self.setOptionArgDict('keyboard', 'keyboardLayout', 'pty')
|
#self.setOptionArgDict('keyboard', 'keyboardLayout', 'pty')
|
||||||
self.setSetting('keyboard', 'keyboardLayout', 'pty')
|
self.setSetting('keyboard', 'keyboardLayout', 'pty')
|
||||||
self.setOptionArgDict('general', 'debugFile', '/tmp/fenrir-pty.log')
|
self.setSetting('general', 'debugFile', '/tmp/fenrir-pty.log')
|
||||||
if cliArgs.emulated_evdev:
|
if cliArgs.emulated_evdev:
|
||||||
self.setOptionArgDict('screen', 'driver', 'ptyDriver')
|
self.setSetting('screen', 'driver', 'ptyDriver')
|
||||||
self.setOptionArgDict('keyboard', 'driver', 'evdevDriver')
|
self.setSetting('keyboard', 'driver', 'evdevDriver')
|
||||||
|
|
||||||
self.setFenrirKeys(self.getSetting('general','fenrirKeys'))
|
self.setFenrirKeys(self.getSetting('general','fenrirKeys'))
|
||||||
self.setScriptKeys(self.getSetting('general','scriptKeys'))
|
self.setScriptKeys(self.getSetting('general','scriptKeys'))
|
||||||
@ -367,4 +388,3 @@ class settingsManager():
|
|||||||
environment['runtime']['debug'].writeDebugOut('\/-------self.settingArgDict-------\/',debug.debugLevel.INFO, onAnyLevel=True)
|
environment['runtime']['debug'].writeDebugOut('\/-------self.settingArgDict-------\/',debug.debugLevel.INFO, onAnyLevel=True)
|
||||||
environment['runtime']['debug'].writeDebugOut(str( self.settingArgDict) ,debug.debugLevel.INFO, onAnyLevel=True)
|
environment['runtime']['debug'].writeDebugOut(str( self.settingArgDict) ,debug.debugLevel.INFO, onAnyLevel=True)
|
||||||
return environment
|
return environment
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user