add debug

This commit is contained in:
chrys 2016-10-01 18:05:23 +02:00
parent fa33b21758
commit 654794de61
7 changed files with 16 additions and 25 deletions

View File

@ -43,8 +43,9 @@ class commandManager():
spec.loader.exec_module(command_mod) spec.loader.exec_module(command_mod)
self.env['commands'][section][fileName.upper()] = command_mod.command() self.env['commands'][section][fileName.upper()] = command_mod.command()
self.env['commands'][section][fileName.upper()].initialize(self.env) self.env['commands'][section][fileName.upper()].initialize(self.env)
self.env['runtime']['debug'].writeDebugOut("Load command:" + section + "." + fileName.upper() ,debug.debugLevel.INFO)
except Exception as e: except Exception as e:
print(e)
self.env['runtime']['debug'].writeDebugOut("Loading command:" + command ,debug.debugLevel.ERROR) self.env['runtime']['debug'].writeDebugOut("Loading command:" + command ,debug.debugLevel.ERROR)
self.env['runtime']['debug'].writeDebugOut(str(e),debug.debugLevel.ERROR) self.env['runtime']['debug'].writeDebugOut(str(e),debug.debugLevel.ERROR)
continue continue
@ -55,7 +56,6 @@ class commandManager():
self.env['commands'][section][command].shutdown() self.env['commands'][section][command].shutdown()
del self.env['commands'][section][command] del self.env['commands'][section][command]
except Exception as e: except Exception as e:
print(e)
self.env['runtime']['debug'].writeDebugOut("Shutdown command:" + section + "." + command ,debug.debugLevel.ERROR) self.env['runtime']['debug'].writeDebugOut("Shutdown command:" + section + "." + command ,debug.debugLevel.ERROR)
self.env['runtime']['debug'].writeDebugOut(str(e),debug.debugLevel.ERROR) self.env['runtime']['debug'].writeDebugOut(str(e),debug.debugLevel.ERROR)
continue continue
@ -67,20 +67,18 @@ class commandManager():
oldScript = unLoadScript oldScript = unLoadScript
if self.commandExists(oldScript, trigger): if self.commandExists(oldScript, trigger):
try: try:
self.env['commands'][trigger][oldScript].unload()
self.env['runtime']['debug'].writeDebugOut("Executing switchtrigger.unload:" + trigger + "." + oldScript ,debug.debugLevel.INFO) self.env['runtime']['debug'].writeDebugOut("Executing switchtrigger.unload:" + trigger + "." + oldScript ,debug.debugLevel.INFO)
self.env['commands'][trigger][oldScript].unload()
except Exception as e: except Exception as e:
print(e)
self.env['runtime']['debug'].writeDebugOut("Executing trigger:" + trigger + "." + oldScript ,debug.debugLevel.ERROR) self.env['runtime']['debug'].writeDebugOut("Executing trigger:" + trigger + "." + oldScript ,debug.debugLevel.ERROR)
self.env['runtime']['debug'].writeDebugOut(str(e),debug.debugLevel.ERROR) self.env['runtime']['debug'].writeDebugOut(str(e),debug.debugLevel.ERROR)
#load #load
newScript = loadScript newScript = loadScript
if self.commandExists(newScript, trigger): if self.commandExists(newScript, trigger):
try: try:
self.env['commands'][trigger][newScript].load()
self.env['runtime']['debug'].writeDebugOut("Executing switchtrigger.load:" + trigger + "." + newScript ,debug.debugLevel.INFO) self.env['runtime']['debug'].writeDebugOut("Executing switchtrigger.load:" + trigger + "." + newScript ,debug.debugLevel.INFO)
self.env['commands'][trigger][newScript].load()
except Exception as e: except Exception as e:
print(e)
self.env['runtime']['debug'].writeDebugOut("Executing trigger:" + trigger + "." + newScript ,debug.debugLevel.ERROR) self.env['runtime']['debug'].writeDebugOut("Executing trigger:" + trigger + "." + newScript ,debug.debugLevel.ERROR)
self.env['runtime']['debug'].writeDebugOut(str(e),debug.debugLevel.ERROR) self.env['runtime']['debug'].writeDebugOut(str(e),debug.debugLevel.ERROR)
@ -90,10 +88,9 @@ class commandManager():
for command in sorted(self.env['commands'][trigger]): for command in sorted(self.env['commands'][trigger]):
if self.commandExists(command, trigger): if self.commandExists(command, trigger):
try: try:
self.env['commands'][trigger][command].run()
self.env['runtime']['debug'].writeDebugOut("Executing trigger.command:" + trigger + "." + command ,debug.debugLevel.INFO) self.env['runtime']['debug'].writeDebugOut("Executing trigger.command:" + trigger + "." + command ,debug.debugLevel.INFO)
self.env['commands'][trigger][command].run()
except Exception as e: except Exception as e:
print(e)
self.env['runtime']['debug'].writeDebugOut("Executing trigger:" + trigger + "." + command ,debug.debugLevel.ERROR) self.env['runtime']['debug'].writeDebugOut("Executing trigger:" + trigger + "." + command ,debug.debugLevel.ERROR)
self.env['runtime']['debug'].writeDebugOut(str(e),debug.debugLevel.ERROR) self.env['runtime']['debug'].writeDebugOut(str(e),debug.debugLevel.ERROR)
@ -103,15 +100,13 @@ class commandManager():
if self.commandExists(command, section): if self.commandExists(command, section):
try: try:
if self.env['generalInformation']['tutorialMode']: if self.env['generalInformation']['tutorialMode']:
self.env['runtime']['debug'].writeDebugOut("Tutorial for command:" + section + "." + command ,debug.debugLevel.INFO)
description = self.env['commands'][section][command].getDescription() description = self.env['commands'][section][command].getDescription()
self.env['runtime']['outputManager'].presentText(description, interrupt=True) self.env['runtime']['outputManager'].presentText(description, interrupt=True)
self.env['runtime']['debug'].writeDebugOut("Tutorial for command:" + section + "." + command ,debug.debugLevel.INFO)
else: else:
self.env['commands'][section][command].run()
self.env['runtime']['debug'].writeDebugOut("Executing command:" + section + "." + command ,debug.debugLevel.INFO) self.env['runtime']['debug'].writeDebugOut("Executing command:" + section + "." + command ,debug.debugLevel.INFO)
self.env['commands'][section][command].run()
except Exception as e: except Exception as e:
print(e)
self.env['runtime']['debug'].writeDebugOut("Executing command:" + section + "." + command ,debug.debugLevel.ERROR) self.env['runtime']['debug'].writeDebugOut("Executing command:" + section + "." + command ,debug.debugLevel.ERROR)
self.env['runtime']['debug'].writeDebugOut(str(e),debug.debugLevel.ERROR) self.env['runtime']['debug'].writeDebugOut(str(e),debug.debugLevel.ERROR)
self.clearCommandQueued() self.clearCommandQueued()

View File

@ -45,8 +45,11 @@ class debug():
else: else:
if not self._fileOpened: if not self._fileOpened:
self.openDebugFile() self.openDebugFile()
self._file.write(str(level) +' ' + str(datetime.utcnow().strftime('%Y-%m-%d %H:%M:%S.%f') msg = str(level) +' ' + str(datetime.utcnow().strftime('%Y-%m-%d %H:%M:%S.%f')
) + ': ' + text + '\n') ) + ': ' + text + '\n'
print(msg)
self._file.write(msg)
def closeDebugFile(self): def closeDebugFile(self):
if not self._fileOpened: if not self._fileOpened:

View File

@ -118,7 +118,6 @@ class inputManager():
time.sleep(0.005) time.sleep(0.005)
self.clearEventBuffer() self.clearEventBuffer()
except Exception as e: except Exception as e:
print(e)
self.env['runtime']['debug'].writeDebugOut("Error while writeUInput",debug.debugLevel.ERROR) self.env['runtime']['debug'].writeDebugOut("Error while writeUInput",debug.debugLevel.ERROR)
self.env['runtime']['debug'].writeDebugOut(str(e),debug.debugLevel.ERROR) self.env['runtime']['debug'].writeDebugOut(str(e),debug.debugLevel.ERROR)

View File

@ -87,7 +87,6 @@ class outputManager():
self.env['runtime']['speechDriver'].speak(text) self.env['runtime']['speechDriver'].speak(text)
self.env['runtime']['debug'].writeDebugOut("Speak: "+ text,debug.debugLevel.INFO) self.env['runtime']['debug'].writeDebugOut("Speak: "+ text,debug.debugLevel.INFO)
except Exception as e: except Exception as e:
print(e)
self.env['runtime']['debug'].writeDebugOut("\"speak\" in outputManager.speakText ",debug.debugLevel.ERROR) self.env['runtime']['debug'].writeDebugOut("\"speak\" in outputManager.speakText ",debug.debugLevel.ERROR)
self.env['runtime']['debug'].writeDebugOut(str(e),debug.debugLevel.ERROR) self.env['runtime']['debug'].writeDebugOut(str(e),debug.debugLevel.ERROR)

View File

@ -30,7 +30,6 @@ class fenrir():
try: try:
self.handleProcess() self.handleProcess()
except Exception as e: except Exception as e:
print(e)
self.environment['runtime']['debug'].writeDebugOut(str(e),debug.debugLevel.ERROR) self.environment['runtime']['debug'].writeDebugOut(str(e),debug.debugLevel.ERROR)
self.shutdown() self.shutdown()
@ -75,7 +74,6 @@ class fenrir():
if self.environment['input']['keyForeward'] > 0: if self.environment['input']['keyForeward'] > 0:
return return
shortcut = self.environment['runtime']['inputManager'].getCurrShortcut() shortcut = self.environment['runtime']['inputManager'].getCurrShortcut()
#print(shortcut)
command = self.environment['runtime']['inputManager'].getCommandForShortcut(shortcut) command = self.environment['runtime']['inputManager'].getCommandForShortcut(shortcut)
if len(self.environment['input']['prevDeepestInput']) <= len(self.environment['input']['currInput']): if len(self.environment['input']['prevDeepestInput']) <= len(self.environment['input']['currInput']):
self.wasCommand = command != '' self.wasCommand = command != ''

View File

@ -83,7 +83,6 @@ class driver():
mEvent['EventState'] = event.value mEvent['EventState'] = event.value
return mEvent return mEvent
except Exception as e: except Exception as e:
print(e)
return None return None
def getNumlock(self): def getNumlock(self):

View File

@ -34,7 +34,6 @@ class driver():
currScreen = self.env['screenData']['newTTY'] currScreen = self.env['screenData']['newTTY']
apps = subprocess.Popen('ps -t tty' + currScreen + ' -o comm,tty,stat', shell=True, stdout=subprocess.PIPE).stdout.read().decode()[:-1].split('\n') apps = subprocess.Popen('ps -t tty' + currScreen + ' -o comm,tty,stat', shell=True, stdout=subprocess.PIPE).stdout.read().decode()[:-1].split('\n')
except Exception as e: except Exception as e:
print(e)
return '' return ''
try: try:
@ -62,7 +61,6 @@ class driver():
try: try:
x = subprocess.Popen('ps a -o tty,comm | grep Xorg', shell=True, stdout=subprocess.PIPE).stdout.read().decode()[:-1].split('\n') x = subprocess.Popen('ps a -o tty,comm | grep Xorg', shell=True, stdout=subprocess.PIPE).stdout.read().decode()[:-1].split('\n')
except Exception as e: except Exception as e:
print(e)
return xlist return xlist
for i in x: for i in x:
if not "grep" in i and \ if not "grep" in i and \