diff --git a/play zone/charmapTTY.py b/play zone/charmapTTY.py old mode 100644 new mode 100755 diff --git a/play zone/daemon.py b/play zone/daemon.py old mode 100644 new mode 100755 diff --git a/play zone/detectDevices.py b/play zone/detectDevices.py old mode 100644 new mode 100755 diff --git a/play zone/parseProcessTree.py b/play zone/parseProcessTree.py old mode 100644 new mode 100755 diff --git a/src/fenrir/core/fenrirManager.py b/src/fenrir/core/fenrirManager.py index d9393987..cc230849 100644 --- a/src/fenrir/core/fenrirManager.py +++ b/src/fenrir/core/fenrirManager.py @@ -13,21 +13,39 @@ if not os.path.dirname(os.path.realpath(__main__.__file__)) in sys.path: from core import i18n from core import settingsManager from core import debug +import argparse class fenrirManager(): def __init__(self): + self.initialized = False + cliArgs = self.handleArgs() + if not cliArgs: + return try: - self.environment = settingsManager.settingsManager().initFenrirConfig() + self.environment = settingsManager.settingsManager().initFenrirConfig(cliArgs) if not self.environment: raise RuntimeError('Cannot Initialize. Maybe the configfile is not available or not parseable') except RuntimeError: raise + self.initialized = True self.environment['runtime']['outputManager'].presentText(_("Start Fenrir"), soundIcon='ScreenReaderOn', interrupt=True) signal.signal(signal.SIGINT, self.captureSignal) signal.signal(signal.SIGTERM, self.captureSignal) self.wasCommand = False - + + def handleArgs(self): + 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') + try: + args = parser.parse_args() + except Exception as e: + parser.print_help() + return args def proceed(self): + if not self.initialized: + return while(self.environment['generalInformation']['running']): try: self.handleProcess() diff --git a/src/fenrir/core/settingsManager.py b/src/fenrir/core/settingsManager.py index ba2c8b95..e0320cf8 100644 --- a/src/fenrir/core/settingsManager.py +++ b/src/fenrir/core/settingsManager.py @@ -205,14 +205,25 @@ class settingsManager(): if not key in self.env['input']['scriptKey']: self.env['input']['scriptKey'].append(key) - def initFenrirConfig(self, environment = environment.environment, settingsRoot = '/etc/fenrir/', settingsFile='settings.conf', soundRoot = '/usr/share/sounds/fenrir/'): + def initFenrirConfig(self, cliArgs, environment = environment.environment): + settingsRoot = '/etc/fenrir/' + settingsFile = cliArgs.setting + soundRoot = '/usr/share/sounds/fenrir/' environment['runtime']['debug'] = debug.debug() environment['runtime']['debug'].initialize(environment) + # get fenrir settings root if not os.path.exists(settingsRoot): if os.path.exists(os.path.dirname(os.path.realpath(__main__.__file__)) +'/../../config/'): settingsRoot = os.path.dirname(os.path.realpath(__main__.__file__)) +'/../../config/' else: return None + # get settings file + if not os.path.exists(settingsFile): + if os.path.exists(settingsRoot + '/settings/' + settingsFile): + settingsFile = settingsRoot + '/settings/' + settingsFile + else: + return None + # get sound themes root if not os.path.exists(soundRoot): if os.path.exists(os.path.dirname(os.path.realpath(__main__.__file__)) +'/../../config/sound/'): soundRoot = os.path.dirname(os.path.realpath(__main__.__file__)) +'/../../config/sound/' @@ -220,7 +231,7 @@ class settingsManager(): environment['runtime']['settingsManager'] = self environment['runtime']['settingsManager'].initialize(environment) - validConfig = environment['runtime']['settingsManager'].loadSettings(settingsRoot + '/settings/' + settingsFile) + validConfig = environment['runtime']['settingsManager'].loadSettings(settingsFile) if not validConfig: return None diff --git a/src/fenrir/inputDriver/evdevDriver.py b/src/fenrir/inputDriver/evdevDriver.py index db295d8b..86e4c379 100644 --- a/src/fenrir/inputDriver/evdevDriver.py +++ b/src/fenrir/inputDriver/evdevDriver.py @@ -113,8 +113,8 @@ class driver(): continue try: open(deviceFile) - except: - print("Not readable Inputdevice : " + deviceFile +' ' + str(e)) + except Exception as e: + self.env['runtime']['debug'].writeDebugOut("Not readable Inputdevice : " + deviceFile +' ' + str(e),debug.debugLevel.ERROR) continue # 3 pos absolute # 2 pos relative @@ -126,26 +126,25 @@ class driver(): if mode in ['ALL','NOMICE']: if eventType.EV_KEY in cap: if 116 in cap[eventType.EV_KEY] and len(cap[eventType.EV_KEY]) < 10: - print('power') continue if len(cap[eventType.EV_KEY]) < 30: - print('Not A useful keyboared') continue if mode == 'ALL': self.iDevices[currDevice.fd] = currDevice self.grabDevice(currDevice.fd) - print('Device added (ALL):' + self.iDevices[currDevice.fd].name) + 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 self.grabDevice(currDevice.fd) - print('Device added (NOMICE):' + self.iDevices[currDevice.fd].name) + self.env['runtime']['debug'].writeDebugOut('Device added (NOMICE):' + self.iDevices[currDevice.fd].name,debug.debugLevel.INFO) elif currDevice.name.upper() in mode.split(','): self.iDevices[currDevice.fd] = currDevice - self.grabDevice(currDevice.fd) - print('Device added (Name):' + self.iDevices[currDevice.fd].name) + self.grabDevice(currDevice.fd) + self.env['runtime']['debug'].writeDebugOut('Device added (Name):' + self.iDevices[currDevice.fd].name,debug.debugLevel.INFO) except Exception as e: - print("Skip Inputdevice : " + deviceFile +' ' + str(e)) + self.env['runtime']['debug'].writeDebugOut("Skip Inputdevice : " + deviceFile +' ' + str(e),debug.debugLevel.ERROR) self.iDeviceNo = len(evdev.list_devices()) def mapEvent(self, event):