The log viewers we use at Khan Academy usually show tracebacks in some kind of escaped format (with newlines replaced with \n
, or the whole thing getting embedded into a large JSON object), so quickly formatting tracebacks has become a pastime for me.
Yesterday I got tired of formatting though, so now I have a fancy tool that can turn the most heinously encoded tracebacks into beautifully formatted emeralds.
Heinous:
'{"test_data": "{\\"data\\": \\"$ tools/runtests.py
\\\\nRUNNING ALL SORTS OF TESTS\\\\nSTUFF IS
PASSING!!\\\\n^CTraceback (most recent call last):\\\\n
File \\\\\\"tools/devshell.py\\\\\\", line 145, in
<module>\\\\n from devshell_eval import *\\\\n File \\
\\\\"webapp/tools/devshell_eval.p
y\\\\\\", line 4, in <module>\\\\n from
assessment_items.models import *\\\\n File \\\\\\"khan27/lib/python2.7/sre_parse.p
y\\\\\\", line 126, in __len__\\\\n def
__len__(self):\\\\nKeyboardInterrupt\\\\n$\\\\n\\",
\\"type\\": \\"traceback\\"}", "test_result": "aborted"}'
Beautiful emerald:
Traceback (most recent call last):
File "tools/devshell.py", line 145, in <module>
from devshell_eval import *
File "webapp/tools/devshell_eval.py", line 4, in <module>
from assessment_items.models import *
File "khan27/lib/python2.7/sre_parse.py", line 126, in __len__
def __len__(self):
KeyboardInterrupt\\\\n$\\\\n\\",
\\"type\\": \\"traceback\\"}", "test_result": "aborted"}'