use debug in outputManager and commandManager

This commit is contained in:
chrys 2016-08-21 23:55:56 +02:00
parent 1467fc1939
commit 5404d1ea17
2 changed files with 59 additions and 14 deletions

View File

@ -23,7 +23,8 @@ class commandManager():
spec.loader.exec_module(command_mod) spec.loader.exec_module(command_mod)
environment['commands'][section][fileName] = command_mod.command() environment['commands'][section][fileName] = command_mod.command()
except Exception as e: 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 continue
return environment return environment
def executeTriggerCommands(self, environment, trigger): def executeTriggerCommands(self, environment, trigger):
@ -33,7 +34,8 @@ class commandManager():
if environ != None: if environ != None:
environment = environ environment = environ
except Exception as e: 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 return environment
def executeCommand(self, environment, currCommand, section = 'commands'): def executeCommand(self, environment, currCommand, section = 'commands'):
@ -43,7 +45,8 @@ class commandManager():
if environ != None: if environ != None:
environment = environ environment = environ
except Exception as e: 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']['currCommand'] = ''
environment['commandInfo']['lastCommandTime'] = time.time() environment['commandInfo']['lastCommandTime'] = time.time()
return environment return environment

View File

@ -1,28 +1,66 @@
#!/bin/python #!/bin/python
from utils import debug
class outputManager(): class outputManager():
def __init__(self): def __init__(self):
pass pass
def presentText(self, environment, text, interrupt=True, soundIcon = ''): 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): if self.playSoundIcon(environment, soundIcon, interrupt):
environment['runtime']['debug'].writeDebugOut(environment,"presentText:\n" + text ,debug.debugLevel.INFO)
return return
self.speakText(environment, text, interrupt) self.speakText(environment, text, interrupt)
self.brailleText(environment, text, interrupt) self.brailleText(environment, text, interrupt)
def speakText(self, environment, text, interrupt=True): def speakText(self, environment, text, interrupt=True):
if not environment['runtime']['settingsManager'].getSettingAsBool(environment, 'speech', 'enabled'): 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: if environment['runtime']['speechDriver'] == None:
environment['runtime']['debug'].writeDebugOut(environment,"Error no speechDriver in outputManager.speakText",debug.debugLevel.ERROR)
return return
if interrupt: if interrupt:
self.interruptOutput(environment) self.interruptOutput(environment)
environment['runtime']['speechDriver'].setLanguage(environment['runtime']['settingsManager'].getSetting(environment, 'speech', 'language')) try:
environment['runtime']['speechDriver'].setVoice(environment['runtime']['settingsManager'].getSetting(environment, 'speech', 'voice')) environment['runtime']['speechDriver'].setLanguage(environment['runtime']['settingsManager'].getSetting(environment, 'speech', 'language'))
environment['runtime']['speechDriver'].setPitch(environment['runtime']['settingsManager'].getSettingAsFloat(environment, 'speech', 'pitch')) except Exception as e:
environment['runtime']['speechDriver'].setRate(environment['runtime']['settingsManager'].getSettingAsFloat(environment, 'speech', 'rate')) environment['runtime']['debug'].writeDebugOut(environment,"Error while setting speech language in outputManager.speakText",debug.debugLevel.ERROR)
environment['runtime']['speechDriver'].setModule(environment['runtime']['settingsManager'].getSetting(environment, 'speech', 'module')) environment['runtime']['debug'].writeDebugOut(environment,str(e),debug.debugLevel.ERROR)
environment['runtime']['speechDriver'].setVolume(environment['runtime']['settingsManager'].getSettingAsFloat(environment, 'speech', 'volume'))
environment['runtime']['speechDriver'].speak(text) 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): def brailleText(self, environment, text, interrupt=True):
if not environment['runtime']['settingsManager'].getSettingAsBool(environment, 'braille', 'enabled'): if not environment['runtime']['settingsManager'].getSettingAsBool(environment, 'braille', 'enabled'):
@ -38,13 +76,17 @@ class outputManager():
if soundIcon == '': if soundIcon == '':
return False return False
if not environment['runtime']['settingsManager'].getSettingAsBool(environment, 'sound', 'enabled'): 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 return False
if environment['runtime']['soundDriver'] == None: if environment['runtime']['soundDriver'] == None:
environment['runtime']['debug'].writeDebugOut(environment,"Error no speechDriver in outputManager.speakText",debug.debugLevel.ERROR)
return False return False
try: try:
environment['runtime']['soundDriver'].setVolume(environment['runtime']['settingsManager'].getSettingAsFloat(environment, 'sound', 'volume')) environment['runtime']['soundDriver'].setVolume(environment['runtime']['settingsManager'].getSettingAsFloat(environment, 'sound', 'volume'))
environment['runtime']['soundDriver'].playSoundFile(environment['soundIcons'][soundIcon], interrupt) environment['runtime']['soundDriver'].playSoundFile(environment['soundIcons'][soundIcon], interrupt)
return True return True
except: except Exception as e:
pass 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 return False