Show More
@@ -1,230 +1,230 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 pprint,pformat |
|
25 | 25 | |
|
26 | 26 | # Our own |
|
27 | 27 | from IPython import Release |
|
28 | 28 | from IPython import ultraTB |
|
29 | 29 | from IPython.ColorANSI import ColorScheme,ColorSchemeTable # too long names |
|
30 | 30 | from IPython.Itpl import Itpl,itpl,printpl |
|
31 | 31 | |
|
32 | 32 | from IPython.genutils import * |
|
33 | 33 | |
|
34 | 34 | #**************************************************************************** |
|
35 | 35 | class CrashHandler: |
|
36 | 36 | """Customizable crash handlers for IPython-based systems. |
|
37 | 37 | |
|
38 | 38 | Instances of this class provide a __call__ method which can be used as a |
|
39 | 39 | sys.excepthook, i.e., the __call__ signature is: |
|
40 | 40 | |
|
41 | 41 | def __call__(self,etype, evalue, etb) |
|
42 | 42 | |
|
43 | 43 | """ |
|
44 | 44 | |
|
45 | 45 | def __init__(self,IP,app_name,contact_name,contact_email, |
|
46 | 46 | bug_tracker,crash_report_fname, |
|
47 | 47 | show_crash_traceback=True): |
|
48 | 48 | """New crash handler. |
|
49 | 49 | |
|
50 | 50 | Inputs: |
|
51 | 51 | |
|
52 | 52 | - IP: a running IPython instance, which will be queried at crash time |
|
53 | 53 | for internal information. |
|
54 | 54 | |
|
55 | 55 | - app_name: a string containing the name of your application. |
|
56 | 56 | |
|
57 | 57 | - contact_name: a string with the name of the person to contact. |
|
58 | 58 | |
|
59 | 59 | - contact_email: a string with the email address of the contact. |
|
60 | 60 | |
|
61 | 61 | - bug_tracker: a string with the URL for your project's bug tracker. |
|
62 | 62 | |
|
63 | 63 | - crash_report_fname: a string with the filename for the crash report |
|
64 | 64 | to be saved in. These reports are left in the ipython user directory |
|
65 | 65 | as determined by the running IPython instance. |
|
66 | 66 | |
|
67 | 67 | Optional inputs: |
|
68 | 68 | |
|
69 | 69 | - show_crash_traceback(True): if false, don't print the crash |
|
70 | 70 | traceback on stderr, only generate the on-disk report |
|
71 | 71 | |
|
72 | 72 | |
|
73 | 73 | Non-argument instance attributes: |
|
74 | 74 | |
|
75 | 75 | These instances contain some non-argument attributes which allow for |
|
76 | 76 | further customization of the crash handler's behavior. Please see the |
|
77 | 77 | source for further details. |
|
78 | 78 | """ |
|
79 | 79 | |
|
80 | 80 | # apply args into instance |
|
81 | 81 | self.IP = IP # IPython instance |
|
82 | 82 | self.app_name = app_name |
|
83 | 83 | self.contact_name = contact_name |
|
84 | 84 | self.contact_email = contact_email |
|
85 | 85 | self.bug_tracker = bug_tracker |
|
86 | 86 | self.crash_report_fname = crash_report_fname |
|
87 | 87 | self.show_crash_traceback = show_crash_traceback |
|
88 | 88 | |
|
89 | 89 | # Hardcoded defaults, which can be overridden either by subclasses or |
|
90 | 90 | # at runtime for the instance. |
|
91 | 91 | |
|
92 | 92 | # Template for the user message. Subclasses which completely override |
|
93 | 93 | # this, or user apps, can modify it to suit their tastes. It gets |
|
94 | 94 | # expanded using itpl, so calls of the kind $self.foo are valid. |
|
95 | 95 | self.user_message_template = """ |
|
96 | 96 | Oops, $self.app_name crashed. We do our best to make it stable, but... |
|
97 | 97 | |
|
98 | 98 | A crash report was automatically generated with the following information: |
|
99 | 99 | - A verbatim copy of the crash traceback. |
|
100 | 100 | - A copy of your input history during this session. |
|
101 | 101 | - Data on your current $self.app_name configuration. |
|
102 | 102 | |
|
103 | 103 | It was left in the file named: |
|
104 | 104 | \t'$self.crash_report_fname' |
|
105 | 105 | If you can email this file to the developers, the information in it will help |
|
106 | 106 | them in understanding and correcting the problem. |
|
107 | 107 | |
|
108 | 108 | You can mail it to: $self.contact_name at $self.contact_email |
|
109 | 109 | with the subject '$self.app_name Crash Report'. |
|
110 | 110 | |
|
111 | 111 | If you want to do it now, the following command will work (under Unix): |
|
112 | 112 | mail -s '$self.app_name Crash Report' $self.contact_email < $self.crash_report_fname |
|
113 | 113 | |
|
114 | 114 | To ensure accurate tracking of this issue, please file a report about it at: |
|
115 | 115 | $self.bug_tracker |
|
116 | 116 | """ |
|
117 | 117 | |
|
118 | 118 | def __call__(self,etype, evalue, etb): |
|
119 | 119 | """Handle an exception, call for compatible with sys.excepthook""" |
|
120 | 120 | |
|
121 | 121 | # Report tracebacks shouldn't use color in general (safer for users) |
|
122 | 122 | color_scheme = 'NoColor' |
|
123 | 123 | |
|
124 | 124 | # Use this ONLY for developer debugging (keep commented out for release) |
|
125 | 125 | #color_scheme = 'Linux' # dbg |
|
126 | 126 | |
|
127 | 127 | try: |
|
128 | 128 | rptdir = self.IP.rc.ipythondir |
|
129 | 129 | except: |
|
130 | 130 | rptdir = os.getcwd() |
|
131 | 131 | if not os.path.isdir(rptdir): |
|
132 | 132 | rptdir = os.getcwd() |
|
133 | 133 | report_name = os.path.join(rptdir,self.crash_report_fname) |
|
134 | 134 | # write the report filename into the instance dict so it can get |
|
135 | 135 | # properly expanded out in the user message template |
|
136 | 136 | self.crash_report_fname = report_name |
|
137 | 137 | TBhandler = ultraTB.VerboseTB(color_scheme=color_scheme, |
|
138 | 138 | long_header=1) |
|
139 | 139 | traceback = TBhandler.text(etype,evalue,etb,context=31) |
|
140 | 140 | |
|
141 | 141 | # print traceback to screen |
|
142 | 142 | if self.show_crash_traceback: |
|
143 | 143 | print >> sys.stderr, traceback |
|
144 | 144 | |
|
145 | 145 | # and generate a complete report on disk |
|
146 | 146 | try: |
|
147 | 147 | report = open(report_name,'w') |
|
148 | 148 | except: |
|
149 | 149 | print >> sys.stderr, 'Could not create crash report on disk.' |
|
150 | 150 | return |
|
151 | 151 | |
|
152 | 152 | # Inform user on stderr of what happened |
|
153 | 153 | msg = itpl('\n'+'*'*70+'\n'+self.user_message_template) |
|
154 | 154 | print >> sys.stderr, msg |
|
155 | 155 | |
|
156 | 156 | # Construct report on disk |
|
157 | 157 | report.write(self.make_report(traceback)) |
|
158 | 158 | report.close() |
|
159 | 159 | raw_input("Press enter to exit:") |
|
160 | 160 | |
|
161 | 161 | def make_report(self,traceback): |
|
162 | 162 | """Return a string containing a crash report.""" |
|
163 | 163 | |
|
164 | 164 | sec_sep = '\n\n'+'*'*75+'\n\n' |
|
165 | 165 | |
|
166 | 166 | report = [] |
|
167 | 167 | rpt_add = report.append |
|
168 | 168 | |
|
169 | 169 | rpt_add('*'*75+'\n\n'+'IPython post-mortem report\n\n') |
|
170 | 170 | rpt_add('IPython version: %s \n\n' % Release.version) |
|
171 | 171 | rpt_add('BZR revision : %s \n\n' % Release.revision) |
|
172 | 172 | rpt_add('Platform info : os.name -> %s, sys.platform -> %s' % |
|
173 | 173 | (os.name,sys.platform) ) |
|
174 | 174 | rpt_add(sec_sep+'Current user configuration structure:\n\n') |
|
175 | 175 | rpt_add(pformat(self.IP.rc.dict())) |
|
176 | 176 | rpt_add(sec_sep+'Crash traceback:\n\n' + traceback) |
|
177 | 177 | try: |
|
178 | 178 | rpt_add(sec_sep+"History of session input:") |
|
179 | 179 | for line in self.IP.user_ns['_ih']: |
|
180 | 180 | rpt_add(line) |
|
181 | 181 | rpt_add('\n*** Last line of input (may not be in above history):\n') |
|
182 | 182 | rpt_add(self.IP._last_input_line+'\n') |
|
183 | 183 | except: |
|
184 | 184 | pass |
|
185 | 185 | |
|
186 | 186 | return ''.join(report) |
|
187 | 187 | |
|
188 | 188 | class IPythonCrashHandler(CrashHandler): |
|
189 | 189 | """sys.excepthook for IPython itself, leaves a detailed report on disk.""" |
|
190 | 190 | |
|
191 | 191 | def __init__(self,IP): |
|
192 | 192 | |
|
193 | 193 | # Set here which of the IPython authors should be listed as contact |
|
194 |
AUTHOR_CONTACT = ' |
|
|
194 | AUTHOR_CONTACT = 'Fernando' | |
|
195 | 195 | |
|
196 | 196 | # Set argument defaults |
|
197 | 197 | app_name = 'IPython' |
|
198 | 198 | bug_tracker = 'https://bugs.launchpad.net/ipython/+filebug' |
|
199 | 199 | contact_name,contact_email = Release.authors[AUTHOR_CONTACT][:2] |
|
200 | 200 | crash_report_fname = 'IPython_crash_report.txt' |
|
201 | 201 | # Call parent constructor |
|
202 | 202 | CrashHandler.__init__(self,IP,app_name,contact_name,contact_email, |
|
203 | 203 | bug_tracker,crash_report_fname) |
|
204 | 204 | |
|
205 | 205 | def make_report(self,traceback): |
|
206 | 206 | """Return a string containing a crash report.""" |
|
207 | 207 | |
|
208 | 208 | sec_sep = '\n\n'+'*'*75+'\n\n' |
|
209 | 209 | |
|
210 | 210 | report = [] |
|
211 | 211 | rpt_add = report.append |
|
212 | 212 | |
|
213 | 213 | rpt_add('*'*75+'\n\n'+'IPython post-mortem report\n\n') |
|
214 | 214 | rpt_add('IPython version: %s \n\n' % Release.version) |
|
215 | 215 | rpt_add('BZR revision : %s \n\n' % Release.revision) |
|
216 | 216 | rpt_add('Platform info : os.name -> %s, sys.platform -> %s' % |
|
217 | 217 | (os.name,sys.platform) ) |
|
218 | 218 | rpt_add(sec_sep+'Current user configuration structure:\n\n') |
|
219 | 219 | rpt_add(pformat(self.IP.rc.dict())) |
|
220 | 220 | rpt_add(sec_sep+'Crash traceback:\n\n' + traceback) |
|
221 | 221 | try: |
|
222 | 222 | rpt_add(sec_sep+"History of session input:") |
|
223 | 223 | for line in self.IP.user_ns['_ih']: |
|
224 | 224 | rpt_add(line) |
|
225 | 225 | rpt_add('\n*** Last line of input (may not be in above history):\n') |
|
226 | 226 | rpt_add(self.IP._last_input_line+'\n') |
|
227 | 227 | except: |
|
228 | 228 | pass |
|
229 | 229 | |
|
230 | 230 | 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 |
|
|
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 |
|
|
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