##// END OF EJS Templates
made myself (vivainio@gmail.com) the default bug contact
vivainio -
Show More
@@ -1,111 +1,111 b''
1 1 # -*- coding: utf-8 -*-
2 2 """sys.excepthook for IPython itself, leaves a detailed report on disk.
3 3
4 $Id: CrashHandler.py 994 2006-01-08 08:29:44Z fperez $"""
4 $Id: CrashHandler.py 1320 2006-05-23 18:29:11Z vivainio $"""
5 5
6 6 #*****************************************************************************
7 7 # Copyright (C) 2001-2006 Fernando Perez. <fperez@colorado.edu>
8 8 #
9 9 # Distributed under the terms of the BSD License. The full license is in
10 10 # the file COPYING, distributed as part of this software.
11 11 #*****************************************************************************
12 12
13 13 from IPython import Release
14 14 __author__ = '%s <%s>' % Release.authors['Fernando']
15 15 __license__ = Release.license
16 16 __version__ = Release.version
17 17
18 18 #****************************************************************************
19 19 # Required modules
20 20
21 21 # From the standard library
22 22 import os
23 23 import sys
24 24 from pprint import pprint,pformat
25 25
26 26 # Homebrewed
27 27 from IPython.Itpl import Itpl,itpl,printpl
28 28 from IPython.ColorANSI import ColorScheme,ColorSchemeTable # too long names
29 29 from IPython import ultraTB
30 30 from IPython.genutils import *
31 31
32 32 #****************************************************************************
33 33 class CrashHandler:
34 34 """sys.excepthook for IPython itself, leaves a detailed report on disk."""
35 35
36 36 def __init__(self,IP):
37 37 self.IP = IP # IPython instance
38 self.bug_contact = Release.authors['Fernando'][0]
39 self.mailto = Release.authors['Fernando'][1]
38 self.bug_contact = Release.authors['Ville'][0]
39 self.mailto = Release.authors['Ville'][1]
40 40
41 41 def __call__(self,etype, evalue, etb):
42 42
43 43 # Report tracebacks shouldn't use color in general (safer for users)
44 44 color_scheme = 'NoColor'
45 45
46 46 # Use this ONLY for developer debugging (keep commented out for release)
47 47 #color_scheme = 'Linux' # dbg
48 48
49 49 try:
50 50 rptdir = self.IP.rc.ipythondir
51 51 except:
52 52 rptdir = os.getcwd()
53 53 if not os.path.isdir(rptdir):
54 54 rptdir = os.getcwd()
55 55 self.report_name = os.path.join(rptdir,'IPython_crash_report.txt')
56 56 self.TBhandler = ultraTB.VerboseTB(color_scheme=color_scheme,long_header=1)
57 57 traceback = self.TBhandler.text(etype,evalue,etb,context=31)
58 58
59 59 # print traceback to screen
60 60 print >> sys.stderr, traceback
61 61
62 62 # and generate a complete report on disk
63 63 try:
64 64 report = open(self.report_name,'w')
65 65 except:
66 66 print >> sys.stderr, 'Could not create crash report on disk.'
67 67 return
68 68
69 69 msg = itpl('\n'+'*'*70+'\n'
70 70 """
71 71 Oops, IPython crashed. We do our best to make it stable, but...
72 72
73 73 A crash report was automatically generated with the following information:
74 74 - A verbatim copy of the traceback above this text.
75 75 - A copy of your input history during this session.
76 76 - Data on your current IPython configuration.
77 77
78 78 It was left in the file named:
79 79 \t'$self.report_name'
80 80 If you can email this file to the developers, the information in it will help
81 81 them in understanding and correcting the problem.
82 82
83 83 You can mail it to $self.bug_contact at $self.mailto
84 84 with the subject 'IPython Crash Report'.
85 85
86 86 If you want to do it now, the following command will work (under Unix):
87 87 mail -s 'IPython Crash Report' $self.mailto < $self.report_name
88 88
89 89 To ensure accurate tracking of this issue, please file a report about it at:
90 90 http://www.scipy.net/roundup/ipython (IPython's online bug tracker).
91 91 """)
92 92 print >> sys.stderr, msg
93 93
94 94 sec_sep = '\n\n'+'*'*75+'\n\n'
95 95 report.write('*'*75+'\n\n'+'IPython post-mortem report\n\n')
96 96 report.write('IPython version: %s \n\n' % Release.version)
97 97 report.write('SVN revision : %s \n\n' % Release.revision)
98 98 report.write('Platform info : os.name -> %s, sys.platform -> %s' %
99 99 (os.name,sys.platform) )
100 100 report.write(sec_sep+'Current user configuration structure:\n\n')
101 101 report.write(pformat(self.IP.rc.dict()))
102 102 report.write(sec_sep+'Crash traceback:\n\n' + traceback)
103 103 try:
104 104 report.write(sec_sep+"History of session input:")
105 105 for line in self.IP.user_ns['_ih']:
106 106 report.write(line)
107 107 report.write('\n*** Last line of input (may not be in above history):\n')
108 108 report.write(self.IP._last_input_line+'\n')
109 109 except:
110 110 pass
111 111 report.close()
General Comments 0
You need to be logged in to leave comments. Login now