Mercurial > p > roundup > code
comparison roundup/cgitb.py @ 485:fad315a10185
i18n'ification
| author | Richard Jones <richard@users.sourceforge.net> |
|---|---|
| date | Sat, 05 Jan 2002 02:22:32 +0000 |
| parents | bdc2ea127ae9 |
| children | e0944187229f |
comparison
equal
deleted
inserted
replaced
| 484:b35f229dd049 | 485:fad315a10185 |
|---|---|
| 1 # | 1 # |
| 2 # This module was written by Ka-Ping Yee, <ping@lfw.org>. | 2 # This module was written by Ka-Ping Yee, <ping@lfw.org>. |
| 3 # | 3 # |
| 4 # $Id: cgitb.py,v 1.7 2001-11-22 15:46:42 jhermann Exp $ | 4 # $Id: cgitb.py,v 1.8 2002-01-05 02:22:32 richard Exp $ |
| 5 | 5 |
| 6 __doc__ = """ | 6 __doc__ = """ |
| 7 Extended CGI traceback handler by Ka-Ping Yee, <ping@lfw.org>. | 7 Extended CGI traceback handler by Ka-Ping Yee, <ping@lfw.org>. |
| 8 """ | 8 """ |
| 9 | 9 |
| 10 import sys, os, types, string, keyword, linecache, tokenize, inspect, pydoc | 10 import sys, os, types, string, keyword, linecache, tokenize, inspect, pydoc |
| 11 | |
| 12 from roundup.i18n import _ | |
| 11 | 13 |
| 12 def breaker(): | 14 def breaker(): |
| 13 return ('<body bgcolor="#f0f0ff">' + | 15 return ('<body bgcolor="#f0f0ff">' + |
| 14 '<font color="#f0f0ff" size="-5"> > </font> ' + | 16 '<font color="#f0f0ff" size="-5"> > </font> ' + |
| 15 '</table>' * 5) | 17 '</table>' * 5) |
| 21 pyver = 'Python ' + string.split(sys.version)[0] + '<br>' + sys.executable | 23 pyver = 'Python ' + string.split(sys.version)[0] + '<br>' + sys.executable |
| 22 head = pydoc.html.heading( | 24 head = pydoc.html.heading( |
| 23 '<font size=+1><strong>%s</strong>: %s</font>'%(str(etype), str(evalue)), | 25 '<font size=+1><strong>%s</strong>: %s</font>'%(str(etype), str(evalue)), |
| 24 '#ffffff', '#aa55cc', pyver) | 26 '#ffffff', '#aa55cc', pyver) |
| 25 | 27 |
| 26 head = head + ('<p>A problem occurred while running a Python script. ' | 28 head = head + (_('<p>A problem occurred while running a Python script. ' |
| 27 'Here is the sequence of function calls leading up to ' | 29 'Here is the sequence of function calls leading up to ' |
| 28 'the error, with the most recent (innermost) call first. ' | 30 'the error, with the most recent (innermost) call first. ' |
| 29 'The exception attributes are:') | 31 'The exception attributes are:')) |
| 30 | 32 |
| 31 indent = '<tt><small>%s</small> </tt>' % (' ' * 5) | 33 indent = '<tt><small>%s</small> </tt>' % (' ' * 5) |
| 32 traceback = [] | 34 traceback = [] |
| 33 for frame, file, lnum, func, lines, index in inspect.trace(context): | 35 for frame, file, lnum, func, lines, index in inspect.trace(context): |
| 34 if file is None: | 36 if file is None: |
| 71 for name in names: | 73 for name in names: |
| 72 if name in frame.f_code.co_varnames: | 74 if name in frame.f_code.co_varnames: |
| 73 if locals.has_key(name): | 75 if locals.has_key(name): |
| 74 value = pydoc.html.repr(locals[name]) | 76 value = pydoc.html.repr(locals[name]) |
| 75 else: | 77 else: |
| 76 value = '<em>undefined</em>' | 78 value = _('<em>undefined</em>') |
| 77 name = '<strong>%s</strong>' % name | 79 name = '<strong>%s</strong>' % name |
| 78 else: | 80 else: |
| 79 if frame.f_globals.has_key(name): | 81 if frame.f_globals.has_key(name): |
| 80 value = pydoc.html.repr(frame.f_globals[name]) | 82 value = pydoc.html.repr(frame.f_globals[name]) |
| 81 else: | 83 else: |
| 82 value = '<em>undefined</em>' | 84 value = _('<em>undefined</em>') |
| 83 name = '<em>global</em> <strong>%s</strong>' % name | 85 name = '<em>global</em> <strong>%s</strong>' % name |
| 84 lvals.append('%s = %s' % (name, value)) | 86 lvals.append('%s = %s' % (name, value)) |
| 85 if lvals: | 87 if lvals: |
| 86 lvals = string.join(lvals, ', ') | 88 lvals = string.join(lvals, ', ') |
| 87 lvals = indent + ''' | 89 lvals = indent + ''' |
| 120 print breaker() | 122 print breaker() |
| 121 print html() | 123 print html() |
| 122 | 124 |
| 123 # | 125 # |
| 124 # $Log: not supported by cvs2svn $ | 126 # $Log: not supported by cvs2svn $ |
| 127 # Revision 1.7 2001/11/22 15:46:42 jhermann | |
| 128 # Added module docstrings to all modules. | |
| 129 # | |
| 125 # Revision 1.6 2001/09/29 13:27:00 richard | 130 # Revision 1.6 2001/09/29 13:27:00 richard |
| 126 # CGI interfaces now spit up a top-level index of all the instances they can | 131 # CGI interfaces now spit up a top-level index of all the instances they can |
| 127 # serve. | 132 # serve. |
| 128 # | 133 # |
| 129 # Revision 1.5 2001/08/07 00:24:42 richard | 134 # Revision 1.5 2001/08/07 00:24:42 richard |
