##// END OF EJS Templates
Merging -r 1199 from lp:ipython.
Brian Granger -
r2153:f0163de9 merge
parent child Browse files
Show More
@@ -1,229 +1,229 b''
1 1 # -*- coding: utf-8 -*-
2 2 """sys.excepthook for IPython itself, leaves a detailed report on disk.
3 3
4 4
5 5 Authors
6 6 -------
7 7 - Fernando Perez <Fernando.Perez@berkeley.edu>
8 8 """
9 9
10 10 #*****************************************************************************
11 11 # Copyright (C) 2008-2009 The IPython Development Team
12 12 # Copyright (C) 2001-2007 Fernando Perez. <fperez@colorado.edu>
13 13 #
14 14 # Distributed under the terms of the BSD License. The full license is in
15 15 # the file COPYING, distributed as part of this software.
16 16 #*****************************************************************************
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 pformat
25 25
26 26 # Our own
27 27 from IPython.core import release
28 28 from IPython.core import ultratb
29 29 from IPython.external.Itpl import itpl
30 30
31 31 from IPython.utils.genutils import *
32 32
33 33 #****************************************************************************
34 34 class CrashHandler:
35 35 """Customizable crash handlers for IPython-based systems.
36 36
37 37 Instances of this class provide a __call__ method which can be used as a
38 38 sys.excepthook, i.e., the __call__ signature is:
39 39
40 40 def __call__(self,etype, evalue, etb)
41 41
42 42 """
43 43
44 44 def __init__(self,IP,app_name,contact_name,contact_email,
45 45 bug_tracker,crash_report_fname,
46 46 show_crash_traceback=True):
47 47 """New crash handler.
48 48
49 49 Inputs:
50 50
51 51 - IP: a running IPython instance, which will be queried at crash time
52 52 for internal information.
53 53
54 54 - app_name: a string containing the name of your application.
55 55
56 56 - contact_name: a string with the name of the person to contact.
57 57
58 58 - contact_email: a string with the email address of the contact.
59 59
60 60 - bug_tracker: a string with the URL for your project's bug tracker.
61 61
62 62 - crash_report_fname: a string with the filename for the crash report
63 63 to be saved in. These reports are left in the ipython user directory
64 64 as determined by the running IPython instance.
65 65
66 66 Optional inputs:
67 67
68 68 - show_crash_traceback(True): if false, don't print the crash
69 69 traceback on stderr, only generate the on-disk report
70 70
71 71
72 72 Non-argument instance attributes:
73 73
74 74 These instances contain some non-argument attributes which allow for
75 75 further customization of the crash handler's behavior. Please see the
76 76 source for further details.
77 77 """
78 78
79 79 # apply args into instance
80 80 self.IP = IP # IPython instance
81 81 self.app_name = app_name
82 82 self.contact_name = contact_name
83 83 self.contact_email = contact_email
84 84 self.bug_tracker = bug_tracker
85 85 self.crash_report_fname = crash_report_fname
86 86 self.show_crash_traceback = show_crash_traceback
87 87
88 88 # Hardcoded defaults, which can be overridden either by subclasses or
89 89 # at runtime for the instance.
90 90
91 91 # Template for the user message. Subclasses which completely override
92 92 # this, or user apps, can modify it to suit their tastes. It gets
93 93 # expanded using itpl, so calls of the kind $self.foo are valid.
94 94 self.user_message_template = """
95 95 Oops, $self.app_name crashed. We do our best to make it stable, but...
96 96
97 97 A crash report was automatically generated with the following information:
98 98 - A verbatim copy of the crash traceback.
99 99 - A copy of your input history during this session.
100 100 - Data on your current $self.app_name configuration.
101 101
102 102 It was left in the file named:
103 103 \t'$self.crash_report_fname'
104 104 If you can email this file to the developers, the information in it will help
105 105 them in understanding and correcting the problem.
106 106
107 107 You can mail it to: $self.contact_name at $self.contact_email
108 108 with the subject '$self.app_name Crash Report'.
109 109
110 110 If you want to do it now, the following command will work (under Unix):
111 111 mail -s '$self.app_name Crash Report' $self.contact_email < $self.crash_report_fname
112 112
113 113 To ensure accurate tracking of this issue, please file a report about it at:
114 114 $self.bug_tracker
115 115 """
116 116
117 117 def __call__(self,etype, evalue, etb):
118 118 """Handle an exception, call for compatible with sys.excepthook"""
119 119
120 120 # Report tracebacks shouldn't use color in general (safer for users)
121 121 color_scheme = 'NoColor'
122 122
123 123 # Use this ONLY for developer debugging (keep commented out for release)
124 124 #color_scheme = 'Linux' # dbg
125 125
126 126 try:
127 127 rptdir = self.IP.rc.ipythondir
128 128 except:
129 129 rptdir = os.getcwd()
130 130 if not os.path.isdir(rptdir):
131 131 rptdir = os.getcwd()
132 132 report_name = os.path.join(rptdir,self.crash_report_fname)
133 133 # write the report filename into the instance dict so it can get
134 134 # properly expanded out in the user message template
135 135 self.crash_report_fname = report_name
136 136 TBhandler = ultratb.VerboseTB(color_scheme=color_scheme,
137 137 long_header=1)
138 138 traceback = TBhandler.text(etype,evalue,etb,context=31)
139 139
140 140 # print traceback to screen
141 141 if self.show_crash_traceback:
142 142 print >> sys.stderr, traceback
143 143
144 144 # and generate a complete report on disk
145 145 try:
146 146 report = open(report_name,'w')
147 147 except:
148 148 print >> sys.stderr, 'Could not create crash report on disk.'
149 149 return
150 150
151 151 # Inform user on stderr of what happened
152 152 msg = itpl('\n'+'*'*70+'\n'+self.user_message_template)
153 153 print >> sys.stderr, msg
154 154
155 155 # Construct report on disk
156 156 report.write(self.make_report(traceback))
157 157 report.close()
158 158 raw_input("Press enter to exit:")
159 159
160 160 def make_report(self,traceback):
161 161 """Return a string containing a crash report."""
162 162
163 163 sec_sep = '\n\n'+'*'*75+'\n\n'
164 164
165 165 report = []
166 166 rpt_add = report.append
167 167
168 168 rpt_add('*'*75+'\n\n'+'IPython post-mortem report\n\n')
169 169 rpt_add('IPython version: %s \n\n' % release.version)
170 170 rpt_add('BZR revision : %s \n\n' % release.revision)
171 171 rpt_add('Platform info : os.name -> %s, sys.platform -> %s' %
172 172 (os.name,sys.platform) )
173 173 rpt_add(sec_sep+'Current user configuration structure:\n\n')
174 174 rpt_add(pformat(self.IP.rc.dict()))
175 175 rpt_add(sec_sep+'Crash traceback:\n\n' + traceback)
176 176 try:
177 177 rpt_add(sec_sep+"History of session input:")
178 178 for line in self.IP.user_ns['_ih']:
179 179 rpt_add(line)
180 180 rpt_add('\n*** Last line of input (may not be in above history):\n')
181 181 rpt_add(self.IP._last_input_line+'\n')
182 182 except:
183 183 pass
184 184
185 185 return ''.join(report)
186 186
187 187 class IPythonCrashHandler(CrashHandler):
188 188 """sys.excepthook for IPython itself, leaves a detailed report on disk."""
189 189
190 190 def __init__(self,IP):
191 191
192 192 # Set here which of the IPython authors should be listed as contact
193 AUTHOR_CONTACT = 'Ville'
193 AUTHOR_CONTACT = 'Fernando'
194 194
195 195 # Set argument defaults
196 196 app_name = 'IPython'
197 197 bug_tracker = 'https://bugs.launchpad.net/ipython/+filebug'
198 198 contact_name,contact_email = release.authors[AUTHOR_CONTACT][:2]
199 199 crash_report_fname = 'IPython_crash_report.txt'
200 200 # Call parent constructor
201 201 CrashHandler.__init__(self,IP,app_name,contact_name,contact_email,
202 202 bug_tracker,crash_report_fname)
203 203
204 204 def make_report(self,traceback):
205 205 """Return a string containing a crash report."""
206 206
207 207 sec_sep = '\n\n'+'*'*75+'\n\n'
208 208
209 209 report = []
210 210 rpt_add = report.append
211 211
212 212 rpt_add('*'*75+'\n\n'+'IPython post-mortem report\n\n')
213 213 rpt_add('IPython version: %s \n\n' % release.version)
214 214 rpt_add('BZR revision : %s \n\n' % release.revision)
215 215 rpt_add('Platform info : os.name -> %s, sys.platform -> %s' %
216 216 (os.name,sys.platform) )
217 217 rpt_add(sec_sep+'Current user configuration structure:\n\n')
218 218 rpt_add(pformat(self.IP.rc.dict()))
219 219 rpt_add(sec_sep+'Crash traceback:\n\n' + traceback)
220 220 try:
221 221 rpt_add(sec_sep+"History of session input:")
222 222 for line in self.IP.user_ns['_ih']:
223 223 rpt_add(line)
224 224 rpt_add('\n*** Last line of input (may not be in above history):\n')
225 225 rpt_add(self.IP._last_input_line+'\n')
226 226 except:
227 227 pass
228 228
229 229 return ''.join(report)
@@ -1,121 +1,121 b''
1 1 # -*- coding: utf-8 -*-
2 2 """Release data for the IPython project."""
3 3
4 4 #*****************************************************************************
5 # Copyright (C) 2001-2006 Fernando Perez <fperez@colorado.edu>
6 #
5 # Copyright (C) 2008-2009 The IPython Development Team
6 # Copyright (C) 2001-2008 Fernando Perez <fperez@colorado.edu>
7 7 # Copyright (c) 2001 Janko Hauser <jhauser@zscout.de> and Nathaniel Gray
8 8 # <n8gray@caltech.edu>
9 9 #
10 10 # Distributed under the terms of the BSD License. The full license is in
11 11 # the file COPYING, distributed as part of this software.
12 12 #*****************************************************************************
13 13
14 14 # Name of the package for release purposes. This is the name which labels
15 15 # the tarballs and RPMs made by distutils, so it's best to lowercase it.
16 16 name = 'ipython'
17 17
18 18 # For versions with substrings (like 0.6.16.svn), use an extra . to separate
19 19 # the new substring. We have to avoid using either dashes or underscores,
20 20 # because bdist_rpm does not accept dashes (an RPM) convention, and
21 21 # bdist_deb does not accept underscores (a Debian convention).
22 22
23 23 development = False # change this to False to do a release
24 version_base = '0.10.rc1'
24 version_base = '0.10'
25 25 branch = 'ipython'
26 26 revision = '1188'
27 27
28 28 if development:
29 29 if branch == 'ipython':
30 30 version = '%s.bzr.r%s' % (version_base, revision)
31 31 else:
32 32 version = '%s.bzr.r%s.%s' % (version_base, revision, branch)
33 33 else:
34 34 version = version_base
35 35
36 36
37 37 description = "An interactive computing environment for Python"
38 38
39 39 long_description = \
40 40 """
41 41 The goal of IPython is to create a comprehensive environment for
42 42 interactive and exploratory computing. To support this goal, IPython
43 43 has two main components:
44 44
45 45 * An enhanced interactive Python shell.
46 46
47 47 * An architecture for interactive parallel computing.
48 48
49 49 The enhanced interactive Python shell has the following main features:
50 50
51 51 * Comprehensive object introspection.
52 52
53 53 * Input history, persistent across sessions.
54 54
55 55 * Caching of output results during a session with automatically generated
56 56 references.
57 57
58 58 * Readline based name completion.
59 59
60 60 * Extensible system of 'magic' commands for controlling the environment and
61 61 performing many tasks related either to IPython or the operating system.
62 62
63 63 * Configuration system with easy switching between different setups (simpler
64 64 than changing $PYTHONSTARTUP environment variables every time).
65 65
66 66 * Session logging and reloading.
67 67
68 68 * Extensible syntax processing for special purpose situations.
69 69
70 70 * Access to the system shell with user-extensible alias system.
71 71
72 72 * Easily embeddable in other Python programs and wxPython GUIs.
73 73
74 74 * Integrated access to the pdb debugger and the Python profiler.
75 75
76 76 The parallel computing architecture has the following main features:
77 77
78 78 * Quickly parallelize Python code from an interactive Python/IPython session.
79 79
80 80 * A flexible and dynamic process model that be deployed on anything from
81 81 multicore workstations to supercomputers.
82 82
83 83 * An architecture that supports many different styles of parallelism, from
84 84 message passing to task farming.
85 85
86 86 * Both blocking and fully asynchronous interfaces.
87 87
88 88 * High level APIs that enable many things to be parallelized in a few lines
89 89 of code.
90 90
91 91 * Share live parallel jobs with other users securely.
92 92
93 93 * Dynamically load balanced task farming system.
94 94
95 95 * Robust error handling in parallel code.
96 96
97 97 The latest development version is always available from IPython's `Launchpad
98 98 site <http://launchpad.net/ipython>`_.
99 99 """
100 100
101 101 license = 'BSD'
102 102
103 authors = {'Fernando' : ('Fernando Perez','fperez@colorado.edu'),
103 authors = {'Fernando' : ('Fernando Perez','fperez.net@gmail.com'),
104 104 'Janko' : ('Janko Hauser','jhauser@zscout.de'),
105 105 'Nathan' : ('Nathaniel Gray','n8gray@caltech.edu'),
106 106 'Ville' : ('Ville Vainio','vivainio@gmail.com'),
107 107 'Brian' : ('Brian E Granger', 'ellisonbg@gmail.com'),
108 108 'Min' : ('Min Ragan-Kelley', 'benjaminrk@gmail.com')
109 109 }
110 110
111 111 author = 'The IPython Development Team'
112 112
113 113 author_email = 'ipython-dev@scipy.org'
114 114
115 115 url = 'http://ipython.scipy.org'
116 116
117 117 download_url = 'http://ipython.scipy.org/dist'
118 118
119 119 platforms = ['Linux','Mac OSX','Windows XP/2000/NT','Windows 95/98/ME']
120 120
121 121 keywords = ['Interactive','Interpreter','Shell','Parallel','Distributed']
General Comments 0
You need to be logged in to leave comments. Login now