summaryrefslogtreecommitdiffstats
path: root/src/Hooks
diff options
context:
space:
mode:
authorJiri Moskovcak <jmoskovc@redhat.com>2009-11-03 14:35:36 +0100
committerJiri Moskovcak <jmoskovc@redhat.com>2009-11-03 14:35:36 +0100
commit19e2c32189cddc8eb377b47cb3107606e683167b (patch)
tree94338f39d21d93d9e7f600a4cdec7ab26cc2972c /src/Hooks
parent7d477ee7e28290812867c40ac7f2ec5a7afdab0c (diff)
downloadabrt-19e2c32189cddc8eb377b47cb3107606e683167b.tar.gz
abrt-19e2c32189cddc8eb377b47cb3107606e683167b.tar.xz
abrt-19e2c32189cddc8eb377b47cb3107606e683167b.zip
add big try-except block to python hook to hide the errors comming from the hok itself
Diffstat (limited to 'src/Hooks')
-rw-r--r--src/Hooks/abrt_exception_handler.py.in89
1 files changed, 46 insertions, 43 deletions
diff --git a/src/Hooks/abrt_exception_handler.py.in b/src/Hooks/abrt_exception_handler.py.in
index 362aaf24..010bf12d 100644
--- a/src/Hooks/abrt_exception_handler.py.in
+++ b/src/Hooks/abrt_exception_handler.py.in
@@ -181,51 +181,54 @@ def handleMyException((etype, value, tb)):
# ignore uncaught ctrl-c
if etype == KeyboardInterrupt:
return sys.__excepthook__(etype, value, tb)
-
- import os.path
- from hashlib import md5
- import traceback
-
- syslog.syslog("abrt: Pyhook: Detected unhandled exception in %s " % sys.argv[0])
- elist = traceback.format_exception (etype, value, tb)
- tblast = traceback.extract_tb(tb, limit=None)
- if len(tblast):
- tblast = tblast[len(tblast)-1]
- extxt = traceback.format_exception_only(etype, value)
- text = ""
- text = text + "Summary: TB"
- if tblast and len(tblast) > 3:
- ll = []
- ll.extend(tblast[:3])
- ll[0] = os.path.basename(tblast[0])
- tblast = ll
-
- m = md5()
- ntext = ""
- for t in tblast:
- ntext += str(t) + ":"
- m.update(str(t))
-
- tb_uuid = str(m.hexdigest())[:8]
- text += tb_uuid + " " + ntext
-
- text += extxt[0]
- text += "\n"
- text += "".join(elist)
-
- trace = tb
- while trace.tb_next:
- trace = trace.tb_next
- frame = trace.tb_frame
- text += ("\nLocal variables in innermost frame:\n")
+
try:
- for (key, val) in frame.f_locals.items():
- text += "%s: %s\n" % (key, val)
- except:
+ import os.path
+ from hashlib import md5
+ import traceback
+
+ syslog.syslog("abrt: Pyhook: Detected unhandled exception in %s " % sys.argv[0])
+ elist = traceback.format_exception (etype, value, tb)
+ tblast = traceback.extract_tb(tb, limit=None)
+ if len(tblast):
+ tblast = tblast[len(tblast)-1]
+ extxt = traceback.format_exception_only(etype, value)
+ text = ""
+ text = text + "Summary: TB"
+ if tblast and len(tblast) > 3:
+ ll = []
+ ll.extend(tblast[:3])
+ ll[0] = os.path.basename(tblast[0])
+ tblast = ll
+
+ m = md5()
+ ntext = ""
+ for t in tblast:
+ ntext += str(t) + ":"
+ m.update(str(t))
+
+ tb_uuid = str(m.hexdigest())[:8]
+ text += tb_uuid + " " + ntext
+
+ text += extxt[0]
+ text += "\n"
+ text += "".join(elist)
+
+ trace = tb
+ while trace.tb_next:
+ trace = trace.tb_next
+ frame = trace.tb_frame
+ text += ("\nLocal variables in innermost frame:\n")
+ try:
+ for (key, val) in frame.f_locals.items():
+ text += "%s: %s\n" % (key, val)
+ except:
+ pass
+
+ # add coredump saving
+ write_dump(os.getpid(), tb_uuid, text)
+ except: #silently ignore any error in this hook, to not interfere with the python scripts
pass
-
- # add coredump saving
- write_dump(os.getpid(), tb_uuid, text)
return sys.__excepthook__(etype, value, tb)
def installExceptionHandler(debug = 1):