Show More
@@ -1,226 +1,228 b'' | |||
|
1 | 1 | # encoding: utf-8 |
|
2 | 2 | """sys.excepthook for IPython itself, leaves a detailed report on disk. |
|
3 | 3 | |
|
4 | 4 | Authors: |
|
5 | 5 | |
|
6 | 6 | * Fernando Perez |
|
7 | 7 | * Brian E. Granger |
|
8 | 8 | """ |
|
9 | 9 | |
|
10 | 10 | #----------------------------------------------------------------------------- |
|
11 | 11 | # Copyright (C) 2001-2007 Fernando Perez. <fperez@colorado.edu> |
|
12 | 12 | # Copyright (C) 2008-2011 The IPython Development Team |
|
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 | # Imports |
|
20 | 20 | #----------------------------------------------------------------------------- |
|
21 | 21 | |
|
22 | 22 | import os |
|
23 | 23 | import sys |
|
24 | 24 | import traceback |
|
25 | 25 | from pprint import pformat |
|
26 | 26 | |
|
27 | 27 | from IPython.core import ultratb |
|
28 | 28 | from IPython.core.release import author_email |
|
29 | 29 | from IPython.utils.sysinfo import sys_info |
|
30 | 30 | from IPython.utils.py3compat import input |
|
31 | 31 | |
|
32 | from IPython.core.release import __version__ as version | |
|
33 | ||
|
32 | 34 | #----------------------------------------------------------------------------- |
|
33 | 35 | # Code |
|
34 | 36 | #----------------------------------------------------------------------------- |
|
35 | 37 | |
|
36 | 38 | # Template for the user message. |
|
37 | 39 | _default_message_template = """\ |
|
38 | 40 | Oops, {app_name} crashed. We do our best to make it stable, but... |
|
39 | 41 | |
|
40 | 42 | A crash report was automatically generated with the following information: |
|
41 | 43 | - A verbatim copy of the crash traceback. |
|
42 | 44 | - A copy of your input history during this session. |
|
43 | 45 | - Data on your current {app_name} configuration. |
|
44 | 46 | |
|
45 | 47 | It was left in the file named: |
|
46 | 48 | \t'{crash_report_fname}' |
|
47 | 49 | If you can email this file to the developers, the information in it will help |
|
48 | 50 | them in understanding and correcting the problem. |
|
49 | 51 | |
|
50 | 52 | You can mail it to: {contact_name} at {contact_email} |
|
51 | 53 | with the subject '{app_name} Crash Report'. |
|
52 | 54 | |
|
53 | 55 | If you want to do it now, the following command will work (under Unix): |
|
54 | 56 | mail -s '{app_name} Crash Report' {contact_email} < {crash_report_fname} |
|
55 | 57 | |
|
56 | 58 | In your email, please also include information about: |
|
57 | 59 | - The operating system under which the crash happened: Linux, macOS, Windows, |
|
58 | 60 | other, and which exact version (for example: Ubuntu 16.04.3, macOS 10.13.2, |
|
59 | 61 | Windows 10 Pro), and whether it is 32-bit or 64-bit; |
|
60 | 62 | - How {app_name} was installed: using pip or conda, from GitHub, as part of |
|
61 | 63 | a Docker container, or other, providing more detail if possible; |
|
62 | 64 | - How to reproduce the crash: what exact sequence of instructions can one |
|
63 | 65 | input to get the same crash? Ideally, find a minimal yet complete sequence |
|
64 | 66 | of instructions that yields the crash. |
|
65 | 67 | |
|
66 | 68 | To ensure accurate tracking of this issue, please file a report about it at: |
|
67 | 69 | {bug_tracker} |
|
68 | 70 | """ |
|
69 | 71 | |
|
70 | 72 | _lite_message_template = """ |
|
71 | If you suspect this is an IPython bug, please report it at: | |
|
73 | If you suspect this is an IPython {version} bug, please report it at: | |
|
72 | 74 | https://github.com/ipython/ipython/issues |
|
73 | 75 | or send an email to the mailing list at {email} |
|
74 | 76 | |
|
75 | 77 | You can print a more detailed traceback right now with "%tb", or use "%debug" |
|
76 | 78 | to interactively debug it. |
|
77 | 79 | |
|
78 | 80 | Extra-detailed tracebacks for bug-reporting purposes can be enabled via: |
|
79 | 81 | {config}Application.verbose_crash=True |
|
80 | 82 | """ |
|
81 | 83 | |
|
82 | 84 | |
|
83 | 85 | class CrashHandler(object): |
|
84 | 86 | """Customizable crash handlers for IPython applications. |
|
85 | 87 | |
|
86 | 88 | Instances of this class provide a :meth:`__call__` method which can be |
|
87 | 89 | used as a ``sys.excepthook``. The :meth:`__call__` signature is:: |
|
88 | 90 | |
|
89 | 91 | def __call__(self, etype, evalue, etb) |
|
90 | 92 | """ |
|
91 | 93 | |
|
92 | 94 | message_template = _default_message_template |
|
93 | 95 | section_sep = '\n\n'+'*'*75+'\n\n' |
|
94 | 96 | |
|
95 | 97 | def __init__(self, app, contact_name=None, contact_email=None, |
|
96 | 98 | bug_tracker=None, show_crash_traceback=True, call_pdb=False): |
|
97 | 99 | """Create a new crash handler |
|
98 | 100 | |
|
99 | 101 | Parameters |
|
100 | 102 | ---------- |
|
101 | 103 | app : Application |
|
102 | 104 | A running :class:`Application` instance, which will be queried at |
|
103 | 105 | crash time for internal information. |
|
104 | 106 | |
|
105 | 107 | contact_name : str |
|
106 | 108 | A string with the name of the person to contact. |
|
107 | 109 | |
|
108 | 110 | contact_email : str |
|
109 | 111 | A string with the email address of the contact. |
|
110 | 112 | |
|
111 | 113 | bug_tracker : str |
|
112 | 114 | A string with the URL for your project's bug tracker. |
|
113 | 115 | |
|
114 | 116 | show_crash_traceback : bool |
|
115 | 117 | If false, don't print the crash traceback on stderr, only generate |
|
116 | 118 | the on-disk report |
|
117 | 119 | |
|
118 | 120 | Non-argument instance attributes: |
|
119 | 121 | |
|
120 | 122 | These instances contain some non-argument attributes which allow for |
|
121 | 123 | further customization of the crash handler's behavior. Please see the |
|
122 | 124 | source for further details. |
|
123 | 125 | """ |
|
124 | 126 | self.crash_report_fname = "Crash_report_%s.txt" % app.name |
|
125 | 127 | self.app = app |
|
126 | 128 | self.call_pdb = call_pdb |
|
127 | 129 | #self.call_pdb = True # dbg |
|
128 | 130 | self.show_crash_traceback = show_crash_traceback |
|
129 | 131 | self.info = dict(app_name = app.name, |
|
130 | 132 | contact_name = contact_name, |
|
131 | 133 | contact_email = contact_email, |
|
132 | 134 | bug_tracker = bug_tracker, |
|
133 | 135 | crash_report_fname = self.crash_report_fname) |
|
134 | 136 | |
|
135 | 137 | |
|
136 | 138 | def __call__(self, etype, evalue, etb): |
|
137 | 139 | """Handle an exception, call for compatible with sys.excepthook""" |
|
138 | 140 | |
|
139 | 141 | # do not allow the crash handler to be called twice without reinstalling it |
|
140 | 142 | # this prevents unlikely errors in the crash handling from entering an |
|
141 | 143 | # infinite loop. |
|
142 | 144 | sys.excepthook = sys.__excepthook__ |
|
143 | 145 | |
|
144 | 146 | # Report tracebacks shouldn't use color in general (safer for users) |
|
145 | 147 | color_scheme = 'NoColor' |
|
146 | 148 | |
|
147 | 149 | # Use this ONLY for developer debugging (keep commented out for release) |
|
148 | 150 | #color_scheme = 'Linux' # dbg |
|
149 | 151 | try: |
|
150 | 152 | rptdir = self.app.ipython_dir |
|
151 | 153 | except: |
|
152 | 154 | rptdir = os.getcwd() |
|
153 | 155 | if rptdir is None or not os.path.isdir(rptdir): |
|
154 | 156 | rptdir = os.getcwd() |
|
155 | 157 | report_name = os.path.join(rptdir,self.crash_report_fname) |
|
156 | 158 | # write the report filename into the instance dict so it can get |
|
157 | 159 | # properly expanded out in the user message template |
|
158 | 160 | self.crash_report_fname = report_name |
|
159 | 161 | self.info['crash_report_fname'] = report_name |
|
160 | 162 | TBhandler = ultratb.VerboseTB( |
|
161 | 163 | color_scheme=color_scheme, |
|
162 | 164 | long_header=1, |
|
163 | 165 | call_pdb=self.call_pdb, |
|
164 | 166 | ) |
|
165 | 167 | if self.call_pdb: |
|
166 | 168 | TBhandler(etype,evalue,etb) |
|
167 | 169 | return |
|
168 | 170 | else: |
|
169 | 171 | traceback = TBhandler.text(etype,evalue,etb,context=31) |
|
170 | 172 | |
|
171 | 173 | # print traceback to screen |
|
172 | 174 | if self.show_crash_traceback: |
|
173 | 175 | print(traceback, file=sys.stderr) |
|
174 | 176 | |
|
175 | 177 | # and generate a complete report on disk |
|
176 | 178 | try: |
|
177 | 179 | report = open(report_name,'w') |
|
178 | 180 | except: |
|
179 | 181 | print('Could not create crash report on disk.', file=sys.stderr) |
|
180 | 182 | return |
|
181 | 183 | |
|
182 | 184 | with report: |
|
183 | 185 | # Inform user on stderr of what happened |
|
184 | 186 | print('\n'+'*'*70+'\n', file=sys.stderr) |
|
185 | 187 | print(self.message_template.format(**self.info), file=sys.stderr) |
|
186 | 188 | |
|
187 | 189 | # Construct report on disk |
|
188 | 190 | report.write(self.make_report(traceback)) |
|
189 | 191 | |
|
190 | 192 | input("Hit <Enter> to quit (your terminal may close):") |
|
191 | 193 | |
|
192 | 194 | def make_report(self,traceback): |
|
193 | 195 | """Return a string containing a crash report.""" |
|
194 | 196 | |
|
195 | 197 | sec_sep = self.section_sep |
|
196 | 198 | |
|
197 | 199 | report = ['*'*75+'\n\n'+'IPython post-mortem report\n\n'] |
|
198 | 200 | rpt_add = report.append |
|
199 | 201 | rpt_add(sys_info()) |
|
200 | 202 | |
|
201 | 203 | try: |
|
202 | 204 | config = pformat(self.app.config) |
|
203 | 205 | rpt_add(sec_sep) |
|
204 | 206 | rpt_add('Application name: %s\n\n' % self.app_name) |
|
205 | 207 | rpt_add('Current user configuration structure:\n\n') |
|
206 | 208 | rpt_add(config) |
|
207 | 209 | except: |
|
208 | 210 | pass |
|
209 | 211 | rpt_add(sec_sep+'Crash traceback:\n\n' + traceback) |
|
210 | 212 | |
|
211 | 213 | return ''.join(report) |
|
212 | 214 | |
|
213 | 215 | |
|
214 | 216 | def crash_handler_lite(etype, evalue, tb): |
|
215 | 217 | """a light excepthook, adding a small message to the usual traceback""" |
|
216 | 218 | traceback.print_exception(etype, evalue, tb) |
|
217 | 219 | |
|
218 | 220 | from IPython.core.interactiveshell import InteractiveShell |
|
219 | 221 | if InteractiveShell.initialized(): |
|
220 | 222 | # we are in a Shell environment, give %magic example |
|
221 | 223 | config = "%config " |
|
222 | 224 | else: |
|
223 | 225 | # we are not in a shell, show generic config |
|
224 | 226 | config = "c." |
|
225 | print(_lite_message_template.format(email=author_email, config=config), file=sys.stderr) | |
|
227 | print(_lite_message_template.format(email=author_email, config=config, version=version), file=sys.stderr) | |
|
226 | 228 |
@@ -1,108 +1,112 b'' | |||
|
1 | 1 | # Simple tool to help for release |
|
2 | 2 | # when releasing with bash, simplei source it to get asked questions. |
|
3 | 3 | |
|
4 | 4 | # misc check before starting |
|
5 | 5 | |
|
6 | 6 | python -c 'import keyring' |
|
7 | 7 | python -c 'import twine' |
|
8 | 8 | python -c 'import sphinx' |
|
9 | 9 | python -c 'import sphinx_rtd_theme' |
|
10 | 10 | python -c 'import nose' |
|
11 | 11 | |
|
12 | 12 | echo -n 'PREV_RELEASE (X.y.z):' |
|
13 | 13 | read PREV_RELEASE |
|
14 | 14 | echo -n 'MILESTONE (X.y):' |
|
15 | 15 | read MILESTONE |
|
16 | 16 | echo -n 'VERSION (X.y.z):' |
|
17 | 17 | read VERSION |
|
18 | 18 | echo -n 'branch (master|X.y):' |
|
19 | 19 | read branch |
|
20 | 20 | |
|
21 | 21 | BLACK=$(tput setaf 1) |
|
22 | 22 | RED=$(tput setaf 1) |
|
23 | 23 | GREEN=$(tput setaf 2) |
|
24 | 24 | YELLOW=$(tput setaf 3) |
|
25 | 25 | BLUE=$(tput setaf 4) |
|
26 | 26 | MAGENTA=$(tput setaf 5) |
|
27 | 27 | CYAN=$(tput setaf 6) |
|
28 | 28 | WHITE=$(tput setaf 7) |
|
29 | 29 | NOR=$(tput sgr0) |
|
30 | 30 | |
|
31 | 31 | echo |
|
32 | 32 | echo $BLUE"Updating what's new with informations from docs/source/whatsnew/pr"$NOR |
|
33 | 33 | python tools/update_whatsnew.py |
|
34 | 34 | |
|
35 | 35 | echo |
|
36 | 36 | echo $BLUE"please move the contents of "docs/source/whatsnew/development.rst" to version-X.rst"$NOR |
|
37 | 37 | echo $GREEN"Press enter to continue"$NOR |
|
38 | 38 | read |
|
39 | 39 | |
|
40 | 40 | echo |
|
41 | 41 | echo $BLUE"here are all the authors that contributed to this release:"$NOR |
|
42 | 42 | git log --format="%aN <%aE>" $PREV_RELEASE... | sort -u -f |
|
43 | 43 | |
|
44 | 44 | echo |
|
45 | 45 | echo $BLUE"If you see any duplicates cancel (Ctrl-C), then edit .mailmap.\n"$GREEN"Press enter to continue:"$NOR |
|
46 | 46 | read |
|
47 | 47 | |
|
48 | 48 | echo $BLUE"generating stats"$NOR |
|
49 | 49 | python tools/github_stats.py --milestone $MILESTONE > stats.rst |
|
50 | 50 | |
|
51 | 51 | echo $BLUE"stats.rst files generated."$NOR |
|
52 | 52 | echo $GREEN"Please merge it with the right file (github-stats-X.rst) and commit."$NOR |
|
53 | 53 | echo $GREEN"press enter to continue."$NOR |
|
54 | 54 | read |
|
55 | 55 | |
|
56 | 56 | echo "Cleaning repository" |
|
57 | 57 | git clean -xfdi |
|
58 | 58 | |
|
59 | 59 | echo $GREEN"please update version number in ${RED}IPython/core/release.py${NOR} , Do not commit yet βΒ we'll do it later."$NOR |
|
60 | 60 | |
|
61 | 61 | echo $GREEN"Press enter to continue"$NOR |
|
62 | 62 | read |
|
63 | 63 | |
|
64 | 64 | echo |
|
65 | 65 | echo "Attempting to build the docs.." |
|
66 | 66 | make html -C docs |
|
67 | 67 | |
|
68 | 68 | echo |
|
69 | 69 | echo $GREEN"Check the docs, press enter to continue"$NOR |
|
70 | 70 | read |
|
71 | 71 | |
|
72 | 72 | echo |
|
73 | 73 | echo $BLUE"Attempting to build package..."$NOR |
|
74 | 74 | |
|
75 | 75 | tools/build_release |
|
76 | 76 | |
|
77 | 77 | echo |
|
78 | 78 | echo "Let's commit : git commit -am \"release $VERSION\" -S" |
|
79 | 79 | echo $GREEN"Press enter to commit"$NOR |
|
80 | 80 | read |
|
81 | 81 | git commit -am "release $VERSION" -S |
|
82 | 82 | |
|
83 | 83 | echo |
|
84 | 84 | echo $BLUE"git push origin \$BRANCH ($BRANCH)?"$NOR |
|
85 | 85 | echo $GREEN"Make sure you can push"$NOR |
|
86 | 86 | echo $GREEN"Press enter to continue"$NOR |
|
87 | 87 | read |
|
88 | 88 | git push origin $BRANCH |
|
89 | 89 | |
|
90 | 90 | echo |
|
91 | 91 | echo "Let's tag : git tag -am \"release $VERSION\" \"$VERSION\" -s" |
|
92 | 92 | echo $GREEN"Press enter to wtagcommit"$NOR |
|
93 | 93 | read |
|
94 | 94 | git tag -am "release $VERSION" "$VERSION" -s |
|
95 | 95 | |
|
96 | 96 | echo |
|
97 | 97 | echo $BLUE"And push the tag: git push origin \$VERSION ?"$NOR |
|
98 | 98 | echo $GREEN"Press enter to continue"$NOR |
|
99 | 99 | read |
|
100 | 100 | git push origin $VERSION |
|
101 | 101 | |
|
102 | 102 | echo |
|
103 | 103 | echo $BLUE"let's : git checkout $VERSION"$NOR |
|
104 | 104 | echo $GREEN"Press enter to continue"$NOR |
|
105 | 105 | read |
|
106 | 106 | git checkout $VERSION |
|
107 | 107 | |
|
108 | # ./tools/release | |
|
109 | # ls ./dist | |
|
110 | # shasum -a 256 dist/* | |
|
111 | ||
|
108 | 112 |
General Comments 0
You need to be logged in to leave comments.
Login now