make X autodetect working, cleanups, remove unecressary returns, shotdown of the drivers in the managers
This commit is contained in:
		| @@ -9,6 +9,9 @@ class commandManager(): | ||||
|     def __init__(self): | ||||
|         pass | ||||
|     def initialize(self, environment): | ||||
|         environment['runtime']['commandManager'].loadCommands(environment,'commands') | ||||
|         environment['runtime']['commandManager'].loadCommands(environment,'onInput') | ||||
|         environment['runtime']['commandManager'].loadCommands(environment,'onScreenChanged')     | ||||
|         return environment | ||||
|     def shutdown(self, environment): | ||||
|         return environment | ||||
| @@ -35,13 +38,11 @@ class commandManager(): | ||||
|         return environment | ||||
|  | ||||
|     def executeTriggerCommands(self, environment, trigger): | ||||
|         if environment['runtime']['screenManager'].isSuspendingScreen(environment) : | ||||
|         if environment['runtime']['screenManager'].isSuspendingScreen(environment): | ||||
|             return environment | ||||
|         for cmd in sorted(environment['commands'][trigger]): | ||||
|             try: | ||||
|                environ = environment['commands'][trigger][cmd].run(environment) | ||||
|                if environ != None: | ||||
|                     environment = environ | ||||
|                environment['commands'][trigger][cmd].run(environment) | ||||
|             except Exception as e: | ||||
|                 print(e) | ||||
|                 environment['runtime']['debug'].writeDebugOut(environment,"Error while executing trigger:" + trigger + "." + cmd ,debug.debugLevel.ERROR) | ||||
| @@ -53,9 +54,7 @@ class commandManager(): | ||||
|             return environment     | ||||
|         if self.isCommandDefined(environment): | ||||
|             try: | ||||
|                 environ =  environment['commands'][section][currCommand].run(environment) | ||||
|                 if environ != None: | ||||
|                     environment = environ | ||||
|                 environment['commands'][section][currCommand].run(environment) | ||||
|             except Exception as e: | ||||
|                 print(e) | ||||
|                 environment['runtime']['debug'].writeDebugOut(environment,"Error while executing command:" + section + "." + currCommand ,debug.debugLevel.ERROR) | ||||
| @@ -70,13 +69,4 @@ class commandManager(): | ||||
|     def setCurrCommandForExec(self, environment, currCommand): | ||||
|         environment['commandInfo']['currCommand'] = currCommand | ||||
|         return environment | ||||
|          | ||||
|     def getCommandForShortcut(self, environment, shortcut): | ||||
|         shortcut = shortcut.upper() | ||||
|         if not self.isShortcutDefined(environment, shortcut): | ||||
|             return ''  | ||||
|         return environment['bindings'][shortcut] | ||||
|  | ||||
|     def isCommandDefined(self, environment, currCommand): | ||||
|         return( currCommand in environment['commands']['commands']) | ||||
|  | ||||
|   | ||||
| @@ -7,16 +7,21 @@ class inputManager(): | ||||
|     def __init__(self): | ||||
|         pass | ||||
|     def initialize(self, environment): | ||||
|         return environment | ||||
|         environment['runtime']['settingsManager'].loadDriver(environment,\ | ||||
|           environment['runtime']['settingsManager'].getSetting(environment,'keyboard', 'driver'), 'inputDriver')      | ||||
|  | ||||
|     def shutdown(self, environment): | ||||
|         return environment | ||||
|         environment['runtime']['inputManager'].releaseDevices(environment)     | ||||
|         if environment['runtime']['inputDriver']: | ||||
|             environment['runtime']['inputDriver'].shutdown(environment) | ||||
|      | ||||
|     def proceedInputEvent(self, environment): | ||||
|         timeout = True    	 | ||||
|         event = environment['runtime']['inputDriver'].getInput(environment) | ||||
|         if event: | ||||
|             timeout = False | ||||
|             print(event) | ||||
|         return environment, timeout | ||||
|             #print(event) | ||||
|         return timeout | ||||
|      | ||||
|     def grabDevices(self, environment): | ||||
|         environment['runtime']['inputDriver'].grabDevices(environment) | ||||
| @@ -47,4 +52,13 @@ class inputManager(): | ||||
|         return str(currShortcutStringList)[1:-1].replace(" ","").replace("'","") | ||||
|          | ||||
|     def isFenrirKey(self,environment, event): | ||||
|         return str(event.code) in environment['input']['fenrirKey']         | ||||
|         return str(event.code) in environment['input']['fenrirKey'] | ||||
|  | ||||
|     def getCommandForShortcut(self, environment, shortcut): | ||||
|         shortcut = shortcut.upper() | ||||
|         if not self.isShortcutDefined(environment, shortcut): | ||||
|             return ''  | ||||
|         return environment['bindings'][shortcut] | ||||
|  | ||||
|     def isCommandDefined(self, environment, currCommand): | ||||
|         return( currCommand in environment['commands']['commands'])  | ||||
|   | ||||
| @@ -5,10 +5,19 @@ class outputManager(): | ||||
|     def __init__(self): | ||||
|         pass | ||||
|     def initialize(self, environment): | ||||
|         return environment | ||||
|         environment['runtime']['settingsManager'].loadDriver(environment,\ | ||||
|           environment['runtime']['settingsManager'].getSetting(environment,'speech', 'driver'), 'speechDriver')     | ||||
|         environment['runtime']['settingsManager'].loadDriver(environment,\ | ||||
|           environment['runtime']['settingsManager'].getSetting(environment,'sound', 'driver'), 'soundDriver')     | ||||
|      | ||||
|     def shutdown(self, environment): | ||||
|         return environment | ||||
|         if environment['runtime']['soundDriver']: | ||||
|             environment['runtime']['soundDriver'].shutdown(environment) | ||||
|         if environment['runtime']['speechDriver']: | ||||
|             environment['runtime']['speechDriver'].shutdown(environment)      | ||||
|  | ||||
|     def presentText(self, environment, text, interrupt=True, soundIcon = ''): | ||||
|         print(soundIcon,text) | ||||
|         environment['runtime']['debug'].writeDebugOut(environment,"presentText:\nsoundIcon:'"+soundIcon+"'\nText:\n" + text ,debug.debugLevel.INFO) | ||||
|         if self.playSoundIcon(environment, soundIcon, interrupt): | ||||
|             environment['runtime']['debug'].writeDebugOut(environment,"soundIcon found" ,debug.debugLevel.INFO)             | ||||
|   | ||||
| @@ -7,14 +7,19 @@ class screenManager(): | ||||
|         self.autoIgnoreScreens = [] | ||||
|  | ||||
|     def initialize(self, environment): | ||||
|         environment['runtime']['settingsManager'].loadDriver(environment,\ | ||||
|           environment['runtime']['settingsManager'].getSetting(environment,'screen', 'driver'), 'screenDriver')     | ||||
|         if environment['runtime']['settingsManager'].getSettingAsBool(environment,'screen', 'autodetectSuspendingScreen'): | ||||
|             self.autoIgnoreScreens = environment['runtime']['screenDriver'].getIgnoreScreens() | ||||
|         return environment | ||||
|          | ||||
|     def shutdown(self, environment): | ||||
|         if environment['runtime']['screenDriver']: | ||||
|             environment['runtime']['screenDriver'].shutdown(environment)     | ||||
|         return environment | ||||
|  | ||||
|     def update(self, environment): | ||||
|         print(self.isSuspendingScreen(environment)) | ||||
|         if not self.isSuspendingScreen(environment): | ||||
|             environment = environment['runtime']['screenDriver'].update(environment) | ||||
|             environment['screenData']['lastScreenUpdate'] = time.time() | ||||
|   | ||||
| @@ -48,7 +48,7 @@ class settingsManager(): | ||||
|             print(str(shortcut)) | ||||
|             environment['bindings'][str(shortcut)] = commandName      | ||||
|         kbConfig.close() | ||||
|         return environment | ||||
|  | ||||
|  | ||||
|     def getCodeForKeyID(self, keyID): | ||||
|         try: | ||||
| @@ -85,10 +85,10 @@ class settingsManager(): | ||||
|  | ||||
|     def loadSettings(self, environment, settingConfigPath): | ||||
|         if not os.path.exists(settingConfigPath): | ||||
|             return None | ||||
|             return False | ||||
|         environment['settings'] = ConfigParser() | ||||
|         environment['settings'].read(settingConfigPath) | ||||
|         return environment | ||||
|         return True | ||||
|  | ||||
|     def setSetting(self, environment, section, setting, value): | ||||
|         environment['settings'].set(section, setting, value) | ||||
| @@ -128,13 +128,13 @@ class settingsManager(): | ||||
|  | ||||
|     def loadDriver(self, environment, driverName, driverType): | ||||
|         if environment['runtime'][driverType] != None: | ||||
|             environment['runtime'][driverType].shutdown()     | ||||
|             print('shutdown %s',driverType) | ||||
|             environment['runtime'][driverType].shutdown(environment)     | ||||
|         spec = importlib.util.spec_from_file_location(driverName, driverType + '/' + driverName + '.py') | ||||
|         driver_mod = importlib.util.module_from_spec(spec) | ||||
|         spec.loader.exec_module(driver_mod) | ||||
|         environment['runtime'][driverType] = driver_mod.driver() | ||||
|         environment['runtime'][driverType].initialize(environment)            | ||||
|         return environment | ||||
|  | ||||
|     def setFenrirKeys(self, environment, keys): | ||||
|         keys = keys.upper() | ||||
| @@ -142,7 +142,6 @@ class settingsManager(): | ||||
|         for key in keyList: | ||||
|             if not key in  environment['input']['fenrirKey']: | ||||
|                 environment['input']['fenrirKey'].append(key) | ||||
|         return environment | ||||
|  | ||||
|     def keyIDasString(self, key): | ||||
|         try: | ||||
| @@ -160,52 +159,39 @@ class settingsManager(): | ||||
|                 return None | ||||
|                 | ||||
|         environment['runtime']['settingsManager'] = self     | ||||
|         environment = environment['runtime']['settingsManager'].loadSettings(environment, settingsRoot + '/settings/' + settingsFile) | ||||
|         if environment == None: | ||||
|         validConfig = environment['runtime']['settingsManager'].loadSettings(environment, settingsRoot + '/settings/' + settingsFile) | ||||
|         if not validConfig: | ||||
|             return None | ||||
|         environment = self.setFenrirKeys(environment, self.getSetting(environment, 'general','fenrirKeys')) | ||||
|         self.setFenrirKeys(environment, self.getSetting(environment, 'general','fenrirKeys')) | ||||
|         if not os.path.exists(self.getSetting(environment, 'keyboard','keyboardLayout')): | ||||
|             if os.path.exists(settingsRoot + 'keyboard/' + self.getSetting(environment, 'keyboard','keyboardLayout')):   | ||||
|                 self.setSetting(environment, 'keyboard', 'keyboardLayout', settingsRoot + 'keyboard/' + self.getSetting(environment, 'keyboard','keyboardLayout')) | ||||
|                 environment = environment['runtime']['settingsManager'].loadShortcuts(environment, self.getSetting('keyboard','keyboardLayout')) | ||||
|                 environment['runtime']['settingsManager'].loadShortcuts(environment, self.getSetting('keyboard','keyboardLayout')) | ||||
|             if os.path.exists(settingsRoot + 'keyboard/' + self.getSetting(environment, 'keyboard','keyboardLayout') + '.conf'):   | ||||
|                 self.setSetting(environment, 'keyboard', 'keyboardLayout', settingsRoot + 'keyboard/' + self.getSetting(environment, 'keyboard','keyboardLayout') + '.conf') | ||||
|                 environment = environment['runtime']['settingsManager'].loadShortcuts(environment, self.getSetting(environment, 'keyboard','keyboardLayout')) | ||||
|                 environment['runtime']['settingsManager'].loadShortcuts(environment, self.getSetting(environment, 'keyboard','keyboardLayout')) | ||||
|         else: | ||||
|             environment = environment['runtime']['settingsManager'].loadShortcuts(environment, self.getSetting(environment, 'keyboard','keyboardLayout')) | ||||
|             environment['runtime']['settingsManager'].loadShortcuts(environment, self.getSetting(environment, 'keyboard','keyboardLayout')) | ||||
|          | ||||
|         if not os.path.exists(self.getSetting(environment, 'sound','theme') + '/soundicons.conf'): | ||||
|             if os.path.exists(settingsRoot + 'sound/'+ self.getSetting(environment, 'sound','theme')):   | ||||
|                 self.setSetting(environment, 'sound', 'theme', settingsRoot + 'sound/'+ self.getSetting(environment, 'sound','theme')) | ||||
|                 if os.path.exists(settingsRoot + 'sound/'+ self.getSetting(environment, 'sound','theme') + '/soundicons.conf'):   | ||||
|                      environment = environment['runtime']['settingsManager'].loadSoundIcons(environment, self.getSetting(environment, 'sound','theme')) | ||||
|                      environment['runtime']['settingsManager'].loadSoundIcons(environment, self.getSetting(environment, 'sound','theme')) | ||||
|         else: | ||||
|             environment = environment['runtime']['settingsManager'].loadSoundIcons(environment, self.getSetting(environment, 'sound','theme')) | ||||
|             environment['runtime']['settingsManager'].loadSoundIcons(environment, self.getSetting(environment, 'sound','theme')) | ||||
|  | ||||
|         environment['runtime']['inputManager'] = inputManager.inputManager() | ||||
|         environment = environment['runtime']['inputManager'].initialize(environment)              | ||||
|         environment['runtime']['inputManager'].initialize(environment)              | ||||
|         environment['runtime']['outputManager'] = outputManager.outputManager() | ||||
|         environment = environment['runtime']['outputManager'].initialize(environment)              | ||||
|         environment['runtime']['outputManager'].initialize(environment)              | ||||
|         environment['runtime']['commandManager'] = commandManager.commandManager() | ||||
|         environment = environment['runtime']['commandManager'].initialize(environment)   | ||||
|         environment['runtime']['commandManager'].initialize(environment)   | ||||
|      | ||||
|         if environment['runtime']['screenManager'] == None: | ||||
|             environment['runtime']['screenManager'] = screenManager.screenManager() | ||||
|             environment = environment['runtime']['screenManager'].initialize(environment)  | ||||
|             environment['runtime']['screenManager'].initialize(environment)  | ||||
|              | ||||
|              | ||||
|         environment = environment['runtime']['commandManager'].loadCommands(environment,'commands') | ||||
|         environment = environment['runtime']['commandManager'].loadCommands(environment,'onInput') | ||||
|         environment = environment['runtime']['commandManager'].loadCommands(environment,'onScreenChanged') | ||||
|  | ||||
|         environment = environment['runtime']['settingsManager'].loadDriver(environment,\ | ||||
|           environment['runtime']['settingsManager'].getSetting(environment,'speech', 'driver'), 'speechDriver') | ||||
|         environment = environment['runtime']['settingsManager'].loadDriver(environment,\ | ||||
|           environment['runtime']['settingsManager'].getSetting(environment,'screen', 'driver'), 'screenDriver') | ||||
|         environment = environment['runtime']['settingsManager'].loadDriver(environment,\ | ||||
|           environment['runtime']['settingsManager'].getSetting(environment,'sound', 'driver'), 'soundDriver') | ||||
|         environment = environment['runtime']['settingsManager'].loadDriver(environment,\ | ||||
|           environment['runtime']['settingsManager'].getSetting(environment,'keyboard', 'driver'), 'inputDriver')  | ||||
|         environment['runtime']['debug'].writeDebugOut(environment,'\/-------environment-------\/',debug.debugLevel.ERROR)         | ||||
|         environment['runtime']['debug'].writeDebugOut(environment,str(environment),debug.debugLevel.ERROR) | ||||
|         environment['runtime']['debug'].writeDebugOut(environment,'\/-------settings.conf-------\/',debug.debugLevel.ERROR)         | ||||
|   | ||||
		Reference in New Issue
	
	Block a user