]> hydra-www.ietfng.org Git - dyna2/commitdiff
added crash summary.
authorTim Vieira <tim.f.vieira@gmail.com>
Thu, 1 Aug 2013 20:01:21 +0000 (16:01 -0400)
committerTim Vieira <tim.f.vieira@gmail.com>
Thu, 1 Aug 2013 20:01:21 +0000 (16:01 -0400)
misc/crash-summary.py [new file with mode: 0644]
src/Dyna/Backend/Python/repl.py

diff --git a/misc/crash-summary.py b/misc/crash-summary.py
new file mode 100644 (file)
index 0000000..6e1b7e4
--- /dev/null
@@ -0,0 +1,60 @@
+"""
+Group similar crashes into a nice colorful summary.
+
+
+$ rsync -a timv-li@login.clsp.jhu.edu:/home/nwf/src/dyna2/crashlogs/. ./.
+
+Expects data to appear in `crashlogs/` directory
+
+"""
+
+import re
+from path import path
+from collections import defaultdict
+
+black, red, green, yellow, blue, magenta, cyan, white = \
+    map('\033[3%sm%%s\033[0m'.__mod__, range(8))
+bold = '\033[1m%s\033[0m'
+
+
+def data():
+    # group data by exception_type / message / traceback
+    d = [(x, x.lines()) for x in path('crashlogs/').glob('*.log')]
+    z = defaultdict(lambda: defaultdict(lambda: defaultdict(list)))
+    for x, ls in d:
+        y = ls[-1]
+        t = y.split(':')[0]
+        tb = '\n'.join(l.strip() for l in ls if '-->' in l)
+        tb2 = re.sub('\033\[[\d;]+m', '', tb)   # remove colors
+        z[t][y][tb].append((x, tb2, ls))
+    return z
+
+
+def show(z, m=3):
+    """
+    m: then number of files to list.
+    """
+    for etype in z:
+        print bold % yellow % '*'*79
+        print etype
+        for msg in z[etype]:
+            print ' ', bold % yellow % '-'*77
+            print ' ', msg.strip()
+            for tb, xs in z[etype][msg].items():
+                print
+                for x, _, _ in xs[:m]:
+                    print ' ', red % bold % x
+                if m is not None and len(xs) > m:
+                    print bold % red % '  %s more...' % (len(xs) - m)
+                print
+                for l in tb.split('\n'):
+                    print '   ', l
+                # show the complete log for first thing
+#                for l in xs[0][2]:
+#                    print '   ', l.rstrip()
+
+
+            print
+
+if __name__ == '__main__':
+    show(data(), m=None)
index 7c30108ad0436e532f07f61a028032ea649149d5..37ceac8130fd42b2a6dcbac516da2e0c2360c499 100644 (file)
@@ -5,6 +5,8 @@ TODO: subscriptions: unsubscribe, only show changes
 
 TODO: help should print call signature of loads and post-processors in addition
 to help.
+
+TODO: check for errors in query and trace
 """
 
 import re, os, cmd, readline