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)
self.env['commands'][section][fileName.upper()] = command_mod.command()
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:
print(e)
self.env['runtime']['debug'].writeDebugOut("Loading command:" + command ,debug.debugLevel.ERROR)
self.env['runtime']['debug'].writeDebugOut(str(e),debug.debugLevel.ERROR)
continue
@ -55,7 +56,6 @@ class commandManager():
self.env['commands'][section][command].shutdown()
del self.env['commands'][section][command]
except Exception as e:
print(e)
self.env['runtime']['debug'].writeDebugOut("Shutdown command:" + section + "." + command ,debug.debugLevel.ERROR)
self.env['runtime']['debug'].writeDebugOut(str(e),debug.debugLevel.ERROR)
continue
@ -67,20 +67,18 @@ class commandManager():
oldScript = unLoadScript
if self.commandExists(oldScript, trigger):
try:
self.env['commands'][trigger][oldScript].unload()
self.env['runtime']['debug'].writeDebugOut("Executing switchtrigger.unload:" + trigger + "." + oldScript ,debug.debugLevel.INFO)
self.env['commands'][trigger][oldScript].unload()
except Exception as e:
print(e)
self.env['runtime']['debug'].writeDebugOut("Executing trigger:" + trigger + "." + oldScript ,debug.debugLevel.ERROR)
self.env['runtime']['debug'].writeDebugOut(str(e),debug.debugLevel.ERROR)
#load
newScript = loadScript
if self.commandExists(newScript, trigger):
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:
print(e)
self.env['runtime']['debug'].writeDebugOut("Executing trigger:" + trigger + "." + newScript ,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]):
if self.commandExists(command, trigger):
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:
print(e)
self.env['runtime']['debug'].writeDebugOut("Executing trigger:" + trigger + "." + command ,debug.debugLevel.ERROR)
self.env['runtime']['debug'].writeDebugOut(str(e),debug.debugLevel.ERROR)
@ -103,15 +100,13 @@ class commandManager():
if self.commandExists(command, section):
try:
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()
self.env['runtime']['outputManager'].presentText(description, interrupt=True)
self.env['runtime']['debug'].writeDebugOut("Tutorial for command:" + section + "." + command ,debug.debugLevel.INFO)
else:
self.env['commands'][section][command].run()
self.env['runtime']['outputManager'].presentText(description, interrupt=True)
else:
self.env['runtime']['debug'].writeDebugOut("Executing command:" + section + "." + command ,debug.debugLevel.INFO)
self.env['commands'][section][command].run()
except Exception as e:
print(e)
self.env['runtime']['debug'].writeDebugOut("Executing command:" + section + "." + command ,debug.debugLevel.ERROR)
self.env['runtime']['debug'].writeDebugOut(str(e),debug.debugLevel.ERROR)
self.clearCommandQueued()

View File

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

View File

@ -118,7 +118,6 @@ class inputManager():
time.sleep(0.005)
self.clearEventBuffer()
except Exception as e:
print(e)
self.env['runtime']['debug'].writeDebugOut("Error while writeUInput",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']['debug'].writeDebugOut("Speak: "+ text,debug.debugLevel.INFO)
except Exception as e:
print(e)
self.env['runtime']['debug'].writeDebugOut("\"speak\" in outputManager.speakText ",debug.debugLevel.ERROR)
self.env['runtime']['debug'].writeDebugOut(str(e),debug.debugLevel.ERROR)

View File

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

View File

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

View File

@ -34,7 +34,6 @@ class driver():
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')
except Exception as e:
print(e)
return ''
try:
@ -62,7 +61,6 @@ class driver():
try:
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:
print(e)
return xlist
for i in x:
if not "grep" in i and \