/usr/lib/python2.7/dist-packages/catcher/collector.py is in python-catcher 0.1.7+git20140530-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 | from collections import namedtuple
import sys
import time
import inspect
Report = namedtuple('Report', ['timestamp', 'exception', 'traceback'])
Frame = namedtuple('Frame', ['file', 'line', 'code', 'locals'])
def __collect_frame(frame):
return Frame(
file=inspect.getfile(frame),
line=frame.f_lineno,
locals=frame.f_locals,
code=inspect.getsourcelines(frame),
)
def backup(exception):
exception.traceback_backup = sys.exc_info()[2]
def collect(exception):
traceback = []
if hasattr(exception, 'traceback_backup'):
tb = exception.traceback_backup
else:
exc_info = sys.exc_info()
tb = exc_info[2]
while tb:
frame = tb.tb_frame
traceback.append(__collect_frame(frame))
tb = tb.tb_next
return Report(
timestamp=time.time(),
exception=exception,
traceback=traceback,
)
|