From 06051f3bea9d5ea95232ef2f36e34069fb9af75f Mon Sep 17 00:00:00 2001 From: bwarsaw Date: Tue, 16 Jun 1998 22:40:21 +0000 Subject: Note! These changes are not being tracked in the old modules directory. print_trace(): Made slightly more robust. Use TQS instead of many print statements. print_environ(): Use TQS instead of many prints. Note: I also removed McLay's name because the contribution is small enough not to need signatures, and the name just confuses things. --- Mailman/debug.py | 64 ++++++++++++++++++++++++++++++++++---------------------- 1 file changed, 39 insertions(+), 25 deletions(-) diff --git a/Mailman/debug.py b/Mailman/debug.py index 5bd96a8c1..659730e98 100644 --- a/Mailman/debug.py +++ b/Mailman/debug.py @@ -13,36 +13,50 @@ # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -# -# debug.py: Utility functions for debugging. -# Michael McLay wrote print_trace(). -# John Viega reconstructed print_environ since it wasn't provided... import sys +import os +import Utils +import traceback + +# We don't use Utils.maketext() here because we want to reduce the critical +# path to getting this page vended. Using Utils.maketext() just introduces +# another path for code that could go wrong. def print_trace(): - print "Content-type: text/html\n" - print "

We're sorry, we hit a bug!

\n" - print "If you would like to help us identify the problem, please " - print "email a copy of this page to the webmaster for this site" - print 'with a description of what happened. Thanks!' - print "\n
"
-    print sys.argv                                           
-    try:                                                        
-        import traceback                                                
-        sys.stderr = sys.stdout
-        traceback.print_exc()                                           
+    print """\
+Content-type: text/html
+
+

We're sorry, we hit a bug!

+ +

If you would like to help us identify the problem, please +email a copy of this page to the webmaster for this site with +a description of what happened. Thanks! + +

+"""
+    print sys.argv
+    try:
+        stderr = sys.stderr
+        try:
+            sys.stderr = sys.stdout
+            traceback.print_exc()
+        finally:
+            sys.stderr = stderr
     except:
-        print "[failed to get traceback]"                     
-    print "\n\n
" + print '[failed to get a traceback]' + print '\n\n
' + +# Same comment as above applies here def print_environ(): - import os - print "


Environment variables:

" - print "" - print "" - print "" - for (x,y) in os.environ.items(): - print "" - print "
VariableValue
", x, "", y, "
" + print '''\ +


Environment variables:

+

+ + +''' + for varname, value in os.environ.items(): + print '' + print '
VariableValue
', varname, '', value, '
' -- cgit v1.3.1