From 5404d1ea17a9f03a5203be9466cf3068187417d8 Mon Sep 17 00:00:00 2001 From: chrys Date: Sun, 21 Aug 2016 23:55:56 +0200 Subject: [PATCH] use debug in outputManager and commandManager --- src/fenrir-package/core/commandManager.py | 9 ++-- src/fenrir-package/core/outputManager.py | 64 +++++++++++++++++++---- 2 files changed, 59 insertions(+), 14 deletions(-) diff --git a/src/fenrir-package/core/commandManager.py b/src/fenrir-package/core/commandManager.py index 6467746e..bb206f8c 100644 --- a/src/fenrir-package/core/commandManager.py +++ b/src/fenrir-package/core/commandManager.py @@ -23,7 +23,8 @@ class commandManager(): spec.loader.exec_module(command_mod) environment['commands'][section][fileName] = command_mod.command() except Exception as e: - print(e) + environment['runtime']['debug'].writeDebugOut(environment,"Error while loading command:" + currCommand ,debug.debugLevel.ERROR) + environment['runtime']['debug'].writeDebugOut(environment,str(e),debug.debugLevel.ERROR) continue return environment def executeTriggerCommands(self, environment, trigger): @@ -33,7 +34,8 @@ class commandManager(): if environ != None: environment = environ except Exception as e: - print(e) + environment['runtime']['debug'].writeDebugOut(environment,"Error while executing trigger:" + trigger + "." + cmd ,debug.debugLevel.ERROR) + environment['runtime']['debug'].writeDebugOut(environment,str(e),debug.debugLevel.ERROR) return environment def executeCommand(self, environment, currCommand, section = 'commands'): @@ -43,7 +45,8 @@ class commandManager(): if environ != None: environment = environ except Exception as e: - print(e) + environment['runtime']['debug'].writeDebugOut(environment,"Error while executing command:" + section + "." + currCommand ,debug.debugLevel.ERROR) + environment['runtime']['debug'].writeDebugOut(environment,str(e),debug.debugLevel.ERROR) environment['commandInfo']['currCommand'] = '' environment['commandInfo']['lastCommandTime'] = time.time() return environment diff --git a/src/fenrir-package/core/outputManager.py b/src/fenrir-package/core/outputManager.py index b2d342d5..ae765c73 100644 --- a/src/fenrir-package/core/outputManager.py +++ b/src/fenrir-package/core/outputManager.py @@ -1,28 +1,66 @@ #!/bin/python - +from utils import debug class outputManager(): def __init__(self): pass def presentText(self, environment, text, interrupt=True, soundIcon = ''): + 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,"presentText:\n" + text ,debug.debugLevel.INFO) return self.speakText(environment, text, interrupt) self.brailleText(environment, text, interrupt) def speakText(self, environment, text, interrupt=True): if not environment['runtime']['settingsManager'].getSettingAsBool(environment, 'speech', 'enabled'): - return + environment['runtime']['debug'].writeDebugOut(environment,"INFO speech disabled in outputManager.speakText",debug.debugLevel.INFO) + return if environment['runtime']['speechDriver'] == None: + environment['runtime']['debug'].writeDebugOut(environment,"Error no speechDriver in outputManager.speakText",debug.debugLevel.ERROR) return if interrupt: self.interruptOutput(environment) - environment['runtime']['speechDriver'].setLanguage(environment['runtime']['settingsManager'].getSetting(environment, 'speech', 'language')) - environment['runtime']['speechDriver'].setVoice(environment['runtime']['settingsManager'].getSetting(environment, 'speech', 'voice')) - environment['runtime']['speechDriver'].setPitch(environment['runtime']['settingsManager'].getSettingAsFloat(environment, 'speech', 'pitch')) - environment['runtime']['speechDriver'].setRate(environment['runtime']['settingsManager'].getSettingAsFloat(environment, 'speech', 'rate')) - environment['runtime']['speechDriver'].setModule(environment['runtime']['settingsManager'].getSetting(environment, 'speech', 'module')) - environment['runtime']['speechDriver'].setVolume(environment['runtime']['settingsManager'].getSettingAsFloat(environment, 'speech', 'volume')) - environment['runtime']['speechDriver'].speak(text) + try: + environment['runtime']['speechDriver'].setLanguage(environment['runtime']['settingsManager'].getSetting(environment, 'speech', 'language')) + except Exception as e: + environment['runtime']['debug'].writeDebugOut(environment,"Error while setting speech language in outputManager.speakText",debug.debugLevel.ERROR) + environment['runtime']['debug'].writeDebugOut(environment,str(e),debug.debugLevel.ERROR) + + try: + environment['runtime']['speechDriver'].setVoice(environment['runtime']['settingsManager'].getSetting(environment, 'speech', 'voice')) + except Exception as e: + environment['runtime']['debug'].writeDebugOut(environment,"Error while setting speech voice in outputManager.speakText",debug.debugLevel.ERROR) + environment['runtime']['debug'].writeDebugOut(environment,str(e),debug.debugLevel.ERROR) + + try: + environment['runtime']['speechDriver'].setPitch(environment['runtime']['settingsManager'].getSettingAsFloat(environment, 'speech', 'pitch')) + except Exception as e: + environment['runtime']['debug'].writeDebugOut(environment,"Error while setting speech pitch in outputManager.speakText",debug.debugLevel.ERROR) + environment['runtime']['debug'].writeDebugOut(environment,str(e),debug.debugLevel.ERROR) + + try: + environment['runtime']['speechDriver'].setRate(environment['runtime']['settingsManager'].getSettingAsFloat(environment, 'speech', 'rate')) + except Exception as e: + environment['runtime']['debug'].writeDebugOut(environment,"Error while setting speech rate in outputManager.speakText",debug.debugLevel.ERROR) + environment['runtime']['debug'].writeDebugOut(environment,str(e),debug.debugLevel.ERROR) + + try: + environment['runtime']['speechDriver'].setModule(environment['runtime']['settingsManager'].getSetting(environment, 'speech', 'module')) + except Exception as e: + environment['runtime']['debug'].writeDebugOut(environment,"Error while setting speech module in outputManager.speakText",debug.debugLevel.ERROR) + environment['runtime']['debug'].writeDebugOut(environment,str(e),debug.debugLevel.ERROR) + + try: + environment['runtime']['speechDriver'].setVolume(environment['runtime']['settingsManager'].getSettingAsFloat(environment, 'speech', 'volume')) + except Exception as e: + environment['runtime']['debug'].writeDebugOut(environment,"Error while setting speech volume in outputManager.speakText ",debug.debugLevel.ERROR) + environment['runtime']['debug'].writeDebugOut(environment,str(e),debug.debugLevel.ERROR) + + try: + environment['runtime']['speechDriver'].speak(text) + except Exception as e: + environment['runtime']['debug'].writeDebugOut(environment,"Error while \"speak\" in outputManager.speakText ",debug.debugLevel.ERROR) + environment['runtime']['debug'].writeDebugOut(environment,str(e),debug.debugLevel.ERROR) def brailleText(self, environment, text, interrupt=True): if not environment['runtime']['settingsManager'].getSettingAsBool(environment, 'braille', 'enabled'): @@ -38,13 +76,17 @@ class outputManager(): if soundIcon == '': return False if not environment['runtime']['settingsManager'].getSettingAsBool(environment, 'sound', 'enabled'): + environment['runtime']['debug'].writeDebugOut(environment,"INFO sound disabled in outputManager.speakText",debug.debugLevel.INFO) return False + if environment['runtime']['soundDriver'] == None: + environment['runtime']['debug'].writeDebugOut(environment,"Error no speechDriver in outputManager.speakText",debug.debugLevel.ERROR) return False try: environment['runtime']['soundDriver'].setVolume(environment['runtime']['settingsManager'].getSettingAsFloat(environment, 'sound', 'volume')) environment['runtime']['soundDriver'].playSoundFile(environment['soundIcons'][soundIcon], interrupt) return True - except: - pass + except Exception as e: + environment['runtime']['debug'].writeDebugOut(environment,"Error while \"playSoundIcon\" in outputManager.speakText ",debug.debugLevel.ERROR) + environment['runtime']['debug'].writeDebugOut(environment,str(e),debug.debugLevel.ERROR) return False