##// END OF EJS Templates
Use str.format instead of Itpl in crash handler.
Thomas Kluyver -
Show More
@@ -24,7 +24,6 b' import sys'
24 from pprint import pformat
24 from pprint import pformat
25
25
26 from IPython.core import ultratb
26 from IPython.core import ultratb
27 from IPython.external.Itpl import itpl
28 from IPython.utils.sysinfo import sys_info
27 from IPython.utils.sysinfo import sys_info
29
28
30 #-----------------------------------------------------------------------------
29 #-----------------------------------------------------------------------------
@@ -33,7 +32,7 b' from IPython.utils.sysinfo import sys_info'
33
32
34 # Template for the user message.
33 # Template for the user message.
35 _default_message_template = """\
34 _default_message_template = """\
36 Oops, $self.app_name crashed. We do our best to make it stable, but...
35 Oops, {app_name} crashed. We do our best to make it stable, but...
37
36
38 A crash report was automatically generated with the following information:
37 A crash report was automatically generated with the following information:
39 - A verbatim copy of the crash traceback.
38 - A verbatim copy of the crash traceback.
@@ -41,18 +40,18 b' A crash report was automatically generated with the following information:'
41 - Data on your current $self.app_name configuration.
40 - Data on your current $self.app_name configuration.
42
41
43 It was left in the file named:
42 It was left in the file named:
44 \t'$self.crash_report_fname'
43 \t'{crash_report_fname}'
45 If you can email this file to the developers, the information in it will help
44 If you can email this file to the developers, the information in it will help
46 them in understanding and correcting the problem.
45 them in understanding and correcting the problem.
47
46
48 You can mail it to: $self.contact_name at $self.contact_email
47 You can mail it to: $self.contact_name at {contact_email}
49 with the subject '$self.app_name Crash Report'.
48 with the subject '{app_name} Crash Report'.
50
49
51 If you want to do it now, the following command will work (under Unix):
50 If you want to do it now, the following command will work (under Unix):
52 mail -s '$self.app_name Crash Report' $self.contact_email < $self.crash_report_fname
51 mail -s '{app_name} Crash Report' {contact_email} < {crash_report_fname}
53
52
54 To ensure accurate tracking of this issue, please file a report about it at:
53 To ensure accurate tracking of this issue, please file a report about it at:
55 $self.bug_tracker
54 {bug_tracker}
56 """
55 """
57
56
58
57
@@ -66,6 +65,7 b' class CrashHandler(object):'
66 """
65 """
67
66
68 message_template = _default_message_template
67 message_template = _default_message_template
68 section_sep = '\n\n'+'*'*75+'\n\n'
69
69
70 def __init__(self, app, contact_name=None, contact_email=None,
70 def __init__(self, app, contact_name=None, contact_email=None,
71 bug_tracker=None, show_crash_traceback=True, call_pdb=False):
71 bug_tracker=None, show_crash_traceback=True, call_pdb=False):
@@ -96,16 +96,17 b' class CrashHandler(object):'
96 further customization of the crash handler's behavior. Please see the
96 further customization of the crash handler's behavior. Please see the
97 source for further details.
97 source for further details.
98 """
98 """
99 self.crash_report_fname = "Crash_report_%s.txt" % app.name
99 self.app = app
100 self.app = app
100 self.app_name = self.app.name
101 self.contact_name = contact_name
102 self.contact_email = contact_email
103 self.bug_tracker = bug_tracker
104 self.crash_report_fname = "Crash_report_%s.txt" % self.app_name
105 self.show_crash_traceback = show_crash_traceback
106 self.section_sep = '\n\n'+'*'*75+'\n\n'
107 self.call_pdb = call_pdb
101 self.call_pdb = call_pdb
108 #self.call_pdb = True # dbg
102 #self.call_pdb = True # dbg
103 self.show_crash_traceback = show_crash_traceback
104 self.info = dict(app_name = app.name,
105 contact_name = contact_name,
106 contact_email = contact_email,
107 bug_tracker = bug_tracker,
108 crash_report_fname = self.crash_report_fname)
109
109
110
110 def __call__(self, etype, evalue, etb):
111 def __call__(self, etype, evalue, etb):
111 """Handle an exception, call for compatible with sys.excepthook"""
112 """Handle an exception, call for compatible with sys.excepthook"""
@@ -148,8 +149,8 b' class CrashHandler(object):'
148 return
149 return
149
150
150 # Inform user on stderr of what happened
151 # Inform user on stderr of what happened
151 msg = itpl('\n'+'*'*70+'\n'+self.message_template)
152 print >> sys.stderr, '\n'+'*'*70+'\n'
152 print >> sys.stderr, msg
153 print >> sys.stderr, self.message_template.format(**self.info)
153
154
154 # Construct report on disk
155 # Construct report on disk
155 report.write(self.make_report(traceback))
156 report.write(self.make_report(traceback))
@@ -62,34 +62,9 b" default_config_file_name = u'ipython_config.py'"
62 # Crash handler for this application
62 # Crash handler for this application
63 #-----------------------------------------------------------------------------
63 #-----------------------------------------------------------------------------
64
64
65 _message_template = """\
66 Oops, $self.app_name crashed. We do our best to make it stable, but...
67
68 A crash report was automatically generated with the following information:
69 - A verbatim copy of the crash traceback.
70 - A copy of your input history during this session.
71 - Data on your current $self.app_name configuration.
72
73 It was left in the file named:
74 \t'$self.crash_report_fname'
75 If you can email this file to the developers, the information in it will help
76 them in understanding and correcting the problem.
77
78 You can mail it to: $self.contact_name at $self.contact_email
79 with the subject '$self.app_name Crash Report'.
80
81 If you want to do it now, the following command will work (under Unix):
82 mail -s '$self.app_name Crash Report' $self.contact_email < $self.crash_report_fname
83
84 To ensure accurate tracking of this issue, please file a report about it at:
85 $self.bug_tracker
86 """
87
88 class IPAppCrashHandler(CrashHandler):
65 class IPAppCrashHandler(CrashHandler):
89 """sys.excepthook for IPython itself, leaves a detailed report on disk."""
66 """sys.excepthook for IPython itself, leaves a detailed report on disk."""
90
67
91 message_template = _message_template
92
93 def __init__(self, app):
68 def __init__(self, app):
94 contact_name = release.authors['Fernando'][0]
69 contact_name = release.authors['Fernando'][0]
95 contact_email = release.authors['Fernando'][1]
70 contact_email = release.authors['Fernando'][1]
General Comments 0
You need to be logged in to leave comments. Login now