From 654794de61480322849b213e0bee72407a89b178 Mon Sep 17 00:00:00 2001 From: chrys Date: Sat, 1 Oct 2016 18:05:23 +0200 Subject: [PATCH] add debug --- src/fenrir-package/core/commandManager.py | 27 +++++++++-------------- src/fenrir-package/core/debug.py | 7 ++++-- src/fenrir-package/core/inputManager.py | 1 - src/fenrir-package/core/outputManager.py | 1 - src/fenrir-package/fenrir.py | 2 -- src/fenrir-package/inputDriver/evdev.py | 1 - src/fenrir-package/screenDriver/linux.py | 2 -- 7 files changed, 16 insertions(+), 25 deletions(-) diff --git a/src/fenrir-package/core/commandManager.py b/src/fenrir-package/core/commandManager.py index b6a8ffd4..423e79ed 100644 --- a/src/fenrir-package/core/commandManager.py +++ b/src/fenrir-package/core/commandManager.py @@ -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() diff --git a/src/fenrir-package/core/debug.py b/src/fenrir-package/core/debug.py index cd630994..7bbfbcf9 100644 --- a/src/fenrir-package/core/debug.py +++ b/src/fenrir-package/core/debug.py @@ -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: diff --git a/src/fenrir-package/core/inputManager.py b/src/fenrir-package/core/inputManager.py index f5309cea..ed3d4445 100644 --- a/src/fenrir-package/core/inputManager.py +++ b/src/fenrir-package/core/inputManager.py @@ -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) diff --git a/src/fenrir-package/core/outputManager.py b/src/fenrir-package/core/outputManager.py index ac7eb603..d9544005 100644 --- a/src/fenrir-package/core/outputManager.py +++ b/src/fenrir-package/core/outputManager.py @@ -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) diff --git a/src/fenrir-package/fenrir.py b/src/fenrir-package/fenrir.py index aa1dc852..a232d2b8 100755 --- a/src/fenrir-package/fenrir.py +++ b/src/fenrir-package/fenrir.py @@ -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 != '' diff --git a/src/fenrir-package/inputDriver/evdev.py b/src/fenrir-package/inputDriver/evdev.py index 9bb262e8..55746dd7 100644 --- a/src/fenrir-package/inputDriver/evdev.py +++ b/src/fenrir-package/inputDriver/evdev.py @@ -83,7 +83,6 @@ class driver(): mEvent['EventState'] = event.value return mEvent except Exception as e: - print(e) return None def getNumlock(self): diff --git a/src/fenrir-package/screenDriver/linux.py b/src/fenrir-package/screenDriver/linux.py index 43d97ae3..e46cf3f8 100644 --- a/src/fenrir-package/screenDriver/linux.py +++ b/src/fenrir-package/screenDriver/linux.py @@ -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 \