merge -o option
This commit is contained in:
commit
f4e0af2401
@ -37,7 +37,7 @@ 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')
|
||||
try:
|
||||
args = parser.parse_args()
|
||||
except Exception as e:
|
||||
|
@ -8,6 +8,7 @@ from core import debug
|
||||
|
||||
generalData = {
|
||||
'running': True,
|
||||
'args': None,
|
||||
'tutorialMode': False,
|
||||
'currUser':'',
|
||||
'prevUser':'',
|
||||
|
@ -24,6 +24,7 @@ from utils import module_utils
|
||||
class settingsManager():
|
||||
def __init__(self):
|
||||
self.settings = settingsData
|
||||
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:
|
||||
@ -153,6 +159,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:
|
||||
@ -161,6 +172,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:
|
||||
@ -169,6 +185,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:
|
||||
@ -205,7 +226,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
|
||||
@ -220,8 +256,8 @@ class settingsManager():
|
||||
return None
|
||||
# get settings file
|
||||
if not os.path.exists(settingsFile):
|
||||
if os.path.exists(settingsRoot + '/settings/' + settingsFile):
|
||||
settingsFile = settingsRoot + '/settings/' + settingsFile
|
||||
if os.path.exists(settingsRoot + '/settings/settings.conf'):
|
||||
settingsFile = settingsRoot + '/settings/settings.conf'
|
||||
else:
|
||||
return None
|
||||
# get sound themes root
|
||||
@ -235,7 +271,8 @@ class settingsManager():
|
||||
validConfig = environment['runtime']['settingsManager'].loadSettings(settingsFile)
|
||||
if not validConfig:
|
||||
return None
|
||||
|
||||
if cliArgs.options != '':
|
||||
self.settingArgDict = self.parseSettingArgs(cliArgs.options)
|
||||
self.setFenrirKeys(self.getSetting('general','fenrirKeys'))
|
||||
self.setScriptKeys(self.getSetting('general','scriptKeys'))
|
||||
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user