add -o parameter
This commit is contained in:
parent
5ccb10d6cc
commit
848f5137ea
@ -19,7 +19,6 @@ class fenrirManager():
|
|||||||
def __init__(self):
|
def __init__(self):
|
||||||
self.initialized = False
|
self.initialized = False
|
||||||
cliArgs = self.handleArgs()
|
cliArgs = self.handleArgs()
|
||||||
print(cliArgs)
|
|
||||||
if not cliArgs:
|
if not cliArgs:
|
||||||
return
|
return
|
||||||
try:
|
try:
|
||||||
|
@ -23,6 +23,7 @@ from utils import module_utils
|
|||||||
class settingsManager():
|
class settingsManager():
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
self.settings = settings
|
self.settings = settings
|
||||||
|
self.settingArgDict = {}
|
||||||
def initialize(self, environment):
|
def initialize(self, environment):
|
||||||
self.env = environment
|
self.env = environment
|
||||||
def shutdown(self):
|
def shutdown(self):
|
||||||
@ -145,6 +146,11 @@ class settingsManager():
|
|||||||
def getSetting(self, section, setting):
|
def getSetting(self, section, setting):
|
||||||
value = ''
|
value = ''
|
||||||
try:
|
try:
|
||||||
|
value = self.settingArgDict[section][setting]
|
||||||
|
return value
|
||||||
|
except:
|
||||||
|
pass
|
||||||
|
try:
|
||||||
value = self.env['settings'].get(section, setting)
|
value = self.env['settings'].get(section, setting)
|
||||||
except:
|
except:
|
||||||
value = str(self.settings[section][setting])
|
value = str(self.settings[section][setting])
|
||||||
@ -152,6 +158,11 @@ class settingsManager():
|
|||||||
|
|
||||||
def getSettingAsInt(self, section, setting):
|
def getSettingAsInt(self, section, setting):
|
||||||
value = 0
|
value = 0
|
||||||
|
try:
|
||||||
|
value = int(self.settingArgDict[section][setting])
|
||||||
|
return value
|
||||||
|
except:
|
||||||
|
pass
|
||||||
try:
|
try:
|
||||||
value = self.env['settings'].getint(section, setting)
|
value = self.env['settings'].getint(section, setting)
|
||||||
except:
|
except:
|
||||||
@ -160,6 +171,11 @@ class settingsManager():
|
|||||||
|
|
||||||
def getSettingAsFloat(self, section, setting):
|
def getSettingAsFloat(self, section, setting):
|
||||||
value = 0.0
|
value = 0.0
|
||||||
|
try:
|
||||||
|
value = float(self.settingArgDict[section][setting])
|
||||||
|
return value
|
||||||
|
except Exception as e:
|
||||||
|
pass
|
||||||
try:
|
try:
|
||||||
value = self.env['settings'].getfloat(section, setting)
|
value = self.env['settings'].getfloat(section, setting)
|
||||||
except:
|
except:
|
||||||
@ -168,6 +184,11 @@ class settingsManager():
|
|||||||
|
|
||||||
def getSettingAsBool(self, section, setting):
|
def getSettingAsBool(self, section, setting):
|
||||||
value = False
|
value = False
|
||||||
|
try:
|
||||||
|
value = self.settingArgDict[section][setting].upper() in ['1','YES','JA','TRUE']
|
||||||
|
return value
|
||||||
|
except Exception as e:
|
||||||
|
pass
|
||||||
try:
|
try:
|
||||||
value = self.env['settings'].getboolean(section, setting)
|
value = self.env['settings'].getboolean(section, setting)
|
||||||
except:
|
except:
|
||||||
@ -204,7 +225,22 @@ class settingsManager():
|
|||||||
for key in keyList:
|
for key in keyList:
|
||||||
if not key in self.env['input']['scriptKey']:
|
if not key in self.env['input']['scriptKey']:
|
||||||
self.env['input']['scriptKey'].append(key)
|
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):
|
def initFenrirConfig(self, cliArgs, environment = environment.environment):
|
||||||
settingsRoot = '/etc/fenrir/'
|
settingsRoot = '/etc/fenrir/'
|
||||||
settingsFile = cliArgs.setting
|
settingsFile = cliArgs.setting
|
||||||
@ -234,7 +270,8 @@ class settingsManager():
|
|||||||
validConfig = environment['runtime']['settingsManager'].loadSettings(settingsFile)
|
validConfig = environment['runtime']['settingsManager'].loadSettings(settingsFile)
|
||||||
if not validConfig:
|
if not validConfig:
|
||||||
return None
|
return None
|
||||||
#print(cliArgs.options)
|
if cliArgs.options != '':
|
||||||
|
self.settingArgDict = self.parseSettingArgs(cliArgs.options)
|
||||||
self.setFenrirKeys(self.getSetting('general','fenrirKeys'))
|
self.setFenrirKeys(self.getSetting('general','fenrirKeys'))
|
||||||
self.setScriptKeys(self.getSetting('general','scriptKeys'))
|
self.setScriptKeys(self.getSetting('general','scriptKeys'))
|
||||||
|
|
||||||
|
@ -133,7 +133,6 @@ class driver():
|
|||||||
self.iDevices[currDevice.fd] = currDevice
|
self.iDevices[currDevice.fd] = currDevice
|
||||||
self.grabDevice(currDevice.fd)
|
self.grabDevice(currDevice.fd)
|
||||||
self.env['runtime']['debug'].writeDebugOut('Device added (ALL):' + self.iDevices[currDevice.fd].name, debug.debugLevel.INFO)
|
self.env['runtime']['debug'].writeDebugOut('Device added (ALL):' + self.iDevices[currDevice.fd].name, debug.debugLevel.INFO)
|
||||||
print()
|
|
||||||
elif mode == 'NOMICE':
|
elif mode == 'NOMICE':
|
||||||
if not ((eventType.EV_REL in cap) or (eventType.EV_ABS in cap)):
|
if not ((eventType.EV_REL in cap) or (eventType.EV_ABS in cap)):
|
||||||
self.iDevices[currDevice.fd] = currDevice
|
self.iDevices[currDevice.fd] = currDevice
|
||||||
|
Loading…
Reference in New Issue
Block a user