From 4cee4b5504da049be6883df6db7dbe697e8f3649 Mon Sep 17 00:00:00 2001 From: chrys Date: Fri, 24 Feb 2017 18:46:12 +0100 Subject: [PATCH] finalize: custom command zone; auto screen detection --- config/settings/espeak.settings.conf | 2 +- config/settings/settings.conf | 2 +- config/settings/settings.conf.chrys | 2 +- config/settings/settings.conf.storm | 2 +- src/fenrir/core/commandManager.py | 16 ++++++++++------ src/fenrir/core/screenManager.py | 2 +- src/fenrir/core/settings.py | 2 +- 7 files changed, 16 insertions(+), 12 deletions(-) diff --git a/config/settings/espeak.settings.conf b/config/settings/espeak.settings.conf index eb9b188b..a02ee623 100644 --- a/config/settings/espeak.settings.conf +++ b/config/settings/espeak.settings.conf @@ -138,7 +138,7 @@ dateFormat=%A, %B %d, %Y autoSpellCheck=True spellCheckLanguage=en_US scriptPath=/usr/share/fenrir/scripts -commandPath=/usr/share/fenrir/command +commandPath=/usr/share/fenrir/commands [focus] cursor=True diff --git a/config/settings/settings.conf b/config/settings/settings.conf index 30d3a926..d7e20f2d 100644 --- a/config/settings/settings.conf +++ b/config/settings/settings.conf @@ -141,7 +141,7 @@ spellCheckLanguage=en_US # path for your scripts "scriptKey" functionality scriptPath=/usr/share/fenrir/scripts # overload commands, and create new one without changing Fenrir default -commandPath=/usr/share/fenrir/command +commandPath=/usr/share/fenrir/commands [focus] #follow the text cursor diff --git a/config/settings/settings.conf.chrys b/config/settings/settings.conf.chrys index ea551699..5023b69b 100644 --- a/config/settings/settings.conf.chrys +++ b/config/settings/settings.conf.chrys @@ -139,7 +139,7 @@ autoSpellCheck=True spellCheckLanguage=en_US scriptPath=/usr/share/fenrir/scripts # overload commands, and create new one without changing Fenrir default -commandPath=/usr/share/fenrir/command +commandPath=/usr/share/fenrir/commands [focus] #follow the text cursor diff --git a/config/settings/settings.conf.storm b/config/settings/settings.conf.storm index cf0d15db..69b3c30a 100644 --- a/config/settings/settings.conf.storm +++ b/config/settings/settings.conf.storm @@ -90,7 +90,7 @@ autoSpellCheck=True spellCheckLanguage=en_US scriptPath=/usr/share/fenrir/scripts # overload commands, and create new one without changing Fenrir default -commandPath=/usr/share/fenrir/command +commandPath=/usr/share/fenrir/commands [focus] #follow the text cursor diff --git a/src/fenrir/core/commandManager.py b/src/fenrir/core/commandManager.py index fe5d4a14..a431eb23 100644 --- a/src/fenrir/core/commandManager.py +++ b/src/fenrir/core/commandManager.py @@ -50,12 +50,12 @@ class commandManager(): def loadCommands(self, section='commands',commandPath=''): if commandPath =='': - commandPath = os.path.dirname(os.path.realpath(__main__.__file__)) + commandPath = os.path.dirname(os.path.realpath(__main__.__file__))+ "/commands/" if not commandPath.endswith('/'): commandPath += '/' - commandFolder = commandPath + "commands/" + section +"/" + commandFolder = commandPath + section +"/" if not os.path.exists(commandFolder): - self.env['runtime']['debug'].writeDebugOut("commandFolder not exists:" + commandFolder ,debug.debugLevel.ERROR) + self.env['runtime']['debug'].writeDebugOut("commandFolder not exists:" + commandFolder ,debug.debugLevel.WARNING) return if not os.path.isdir(commandFolder): self.env['runtime']['debug'].writeDebugOut("commandFolder not a directory:" + commandFolder ,debug.debugLevel.ERROR) @@ -63,6 +63,7 @@ class commandManager(): if not os.access(commandFolder, os.R_OK): self.env['runtime']['debug'].writeDebugOut("commandFolder not readable:" + commandFolder ,debug.debugLevel.ERROR) return + print(commandFolder) commandList = glob.glob(commandFolder+'*') for command in commandList: try: @@ -70,8 +71,11 @@ class commandManager(): fileName = fileName.split('/')[-1] if fileName.startswith('__'): continue - if self.env['commands'][section][fileName.upper()]: - continue + try: + if self.env['commands'][section][fileName.upper()] != None: + continue + except: + pass if fileExtension.lower() == '.py': command_mod = module_utils.importModule(fileName, command) self.env['commands'][section][fileName.upper()] = command_mod.command() @@ -79,7 +83,7 @@ class commandManager(): self.env['commands'][section][fileName.upper()].initialize(self.env) self.env['runtime']['debug'].writeDebugOut("Load command:" + section + "." + fileName.upper() ,debug.debugLevel.INFO, onAnyLevel=True) except Exception as e: - print(e) + print(command+str(e)) self.env['runtime']['debug'].writeDebugOut("Loading command:" + command ,debug.debugLevel.ERROR) self.env['runtime']['debug'].writeDebugOut(str(e),debug.debugLevel.ERROR) continue diff --git a/src/fenrir/core/screenManager.py b/src/fenrir/core/screenManager.py index a2fe74e4..8721f7df 100644 --- a/src/fenrir/core/screenManager.py +++ b/src/fenrir/core/screenManager.py @@ -41,7 +41,7 @@ class screenManager(): if fixIgnoreScreens != '': ignoreScreens.append(fixIgnoreScreens.split(',')) if self.env['runtime']['settingsManager'].getSettingAsBool('screen', 'autodetectSuspendingScreen'): - ignoreScreens.append(self.env['screenData']['autoIgnoreScreens']) + ignoreScreens.extend(self.env['screenData']['autoIgnoreScreens']) return (screen in ignoreScreens) def isScreenChange(self): diff --git a/src/fenrir/core/settings.py b/src/fenrir/core/settings.py index ceadae88..f59c9adc 100644 --- a/src/fenrir/core/settings.py +++ b/src/fenrir/core/settings.py @@ -60,7 +60,7 @@ settings = { 'autoSpellCheck': False, 'spellCheckLanguage': 'en_US', 'scriptPath':'/usr/share/fenrir/scripts', - 'commandPath':'/usr/share/fenrir/command', + 'commandPath':'/usr/share/fenrir/commands', }, 'focus':{ 'cursor': True,