From 047dc87859cc5d1a769170ac7695ac5d54e44709 Mon Sep 17 00:00:00 2001 From: Gerard Wagener Date: Wed, 20 Jan 2010 10:00:16 +0100 Subject: [PATCH] Traceback exceptions --- aha/aha-worker.py | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/aha/aha-worker.py b/aha/aha-worker.py index ecfd8b8796a..d3b25128a72 100644 --- a/aha/aha-worker.py +++ b/aha/aha-worker.py @@ -10,7 +10,7 @@ #The aha framework can be launched then in screen # #TODO implement signal handler HUP flushes the file -import dircache,os.path,time,sys,ConfigParser,getopt +import dircache,os.path,time,sys,ConfigParser,getopt, traceback from ahalib import * class PeriodTaks(): @@ -66,7 +66,12 @@ class PeriodTaks(): try: self.remove_old_msg(self.inqueue) except OSError,e: - sys.stderr.write("%s\n"%str(e)) + exceptionType, exceptionValue, exceptionTraceback = sys.exc_info() + traceback.print_exception(exceptionType, exceptionValue, + exceptionTraceback, file=sys.stderr) + traceback.print_tb(exceptionTraceback, file=sys.stdout) + + def maintain_process_tree(self,mlist,exportFile): if mlist == None: @@ -118,7 +123,10 @@ class PeriodTaks(): #Propagate message list for further processor return mlist except OSError,e: - sys.stderr.write("%s\n"%(str(e))) + exceptionType, exceptionValue, exceptionTraceback = sys.exc_info() + traceback.print_exception(exceptionType, exceptionValue, + exceptionTraceback, file=sys.stderr) + traceback.print_tb(exceptionTraceback, file=sys.stdout) #Parse the file an put the information in a log file for later processing #One log file is handier than for each message a file