add -o parameter

This commit is contained in:
chrys 2017-05-06 00:26:42 +02:00
parent 5ccb10d6cc
commit 848f5137ea
3 changed files with 39 additions and 4 deletions

View File

@ -19,7 +19,6 @@ class fenrirManager():
def __init__(self):
self.initialized = False
cliArgs = self.handleArgs()
print(cliArgs)
if not cliArgs:
return
try:

View File

@ -23,6 +23,7 @@ from utils import module_utils
class settingsManager():
def __init__(self):
self.settings = settings
self.settingArgDict = {}
def initialize(self, environment):
self.env = environment
def shutdown(self):
@ -145,6 +146,11 @@ class settingsManager():
def getSetting(self, section, setting):
value = ''
try:
value = self.settingArgDict[section][setting]
return value
except:
pass
try:
value = self.env['settings'].get(section, setting)
except:
value = str(self.settings[section][setting])
@ -152,6 +158,11 @@ class settingsManager():
def getSettingAsInt(self, section, setting):
value = 0
try:
value = int(self.settingArgDict[section][setting])
return value
except:
pass
try:
value = self.env['settings'].getint(section, setting)
except:
@ -160,6 +171,11 @@ class settingsManager():
def getSettingAsFloat(self, section, setting):
value = 0.0
try:
value = float(self.settingArgDict[section][setting])
return value
except Exception as e:
pass
try:
value = self.env['settings'].getfloat(section, setting)
except:
@ -168,6 +184,11 @@ class settingsManager():
def getSettingAsBool(self, section, setting):
value = False
try:
value = self.settingArgDict[section][setting].upper() in ['1','YES','JA','TRUE']
return value
except Exception as e:
pass
try:
value = self.env['settings'].getboolean(section, setting)
except:
@ -204,7 +225,22 @@ class settingsManager():
for key in keyList:
if not key in self.env['input']['scriptKey']:
self.env['input']['scriptKey'].append(key)
def parseSettingArgs(self, settingArgs):
optionArgDict = {}
for optionElem in settingArgs.split(';'):
if len(optionElem.split('#',1)) != 2:
continue
if len(optionElem.split('#',1)[1].split('=',1)) != 2:
continue
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)
return optionArgDict
def initFenrirConfig(self, cliArgs, environment = environment.environment):
settingsRoot = '/etc/fenrir/'
settingsFile = cliArgs.setting
@ -234,7 +270,8 @@ class settingsManager():
validConfig = environment['runtime']['settingsManager'].loadSettings(settingsFile)
if not validConfig:
return None
#print(cliArgs.options)
if cliArgs.options != '':
self.settingArgDict = self.parseSettingArgs(cliArgs.options)
self.setFenrirKeys(self.getSetting('general','fenrirKeys'))
self.setScriptKeys(self.getSetting('general','scriptKeys'))

View File

@ -133,7 +133,6 @@ class driver():
self.iDevices[currDevice.fd] = currDevice
self.grabDevice(currDevice.fd)
self.env['runtime']['debug'].writeDebugOut('Device added (ALL):' + self.iDevices[currDevice.fd].name, debug.debugLevel.INFO)
print()
elif mode == 'NOMICE':
if not ((eventType.EV_REL in cap) or (eventType.EV_ABS in cap)):
self.iDevices[currDevice.fd] = currDevice