From 261f275efdfb11dc1c332e33a6ca34273492f222 Mon Sep 17 00:00:00 2001 From: stv Date: Wed, 26 Nov 2014 01:04:37 -0500 Subject: [PATCH] Remove antiquated trace script This library was originally written to trace local variables. In the more than two years since it was originally written, the only update it has received was to remove PEP8/PyLint/quality violations. It's hard to imagine that this is still useful to anyone, though I'm open to discussion. --- common/lib/supertrace.py | 51 ---------------------------------------- 1 file changed, 51 deletions(-) delete mode 100644 common/lib/supertrace.py diff --git a/common/lib/supertrace.py b/common/lib/supertrace.py deleted file mode 100644 index 83dfa12031..0000000000 --- a/common/lib/supertrace.py +++ /dev/null @@ -1,51 +0,0 @@ -""" -A handy util to print a django-debug-screen-like stack trace with -values of local variables. -""" - -import sys -import traceback -from django.utils.encoding import smart_unicode - - -def supertrace(max_len=160): - """ - Print the usual traceback information, followed by a listing of all the - local variables in each frame. Should be called from an exception handler. - - if max_len is not None, will print up to max_len chars for each local variable. - - (cite: modified from somewhere on stackoverflow) - """ - tb = sys.exc_info()[2] - while True: - if not tb.tb_next: - break - tb = tb.tb_next - stack = [] - frame = tb.tb_frame - while frame: - stack.append(f) - frame = frame.f_back - stack.reverse() - # First print the regular traceback - traceback.print_exc() - - print "Locals by frame, innermost last" - for frame in stack: - print - print "Frame %s in %s at line %s" % (frame.f_code.co_name, - frame.f_code.co_filename, - frame.f_lineno) - for key, value in frame.f_locals.items(): - print ("\t%20s = " % smart_unicode(key, errors='ignore')), - # We have to be careful not to cause a new error in our error - # printer! Calling str() on an unknown object could cause an - # error. - try: - s = smart_unicode(value, errors='ignore') - if max_len is not None: - s = s[:max_len] - print s - except: - print ""