for debugging - print stack in case of exceptions caught at toplevel
authorThierry Parmentelat <thierry.parmentelat@inria.fr>
Wed, 16 Apr 2014 06:24:15 +0000 (08:24 +0200)
committerThierry Parmentelat <thierry.parmentelat@inria.fr>
Wed, 16 Apr 2014 06:24:15 +0000 (08:24 +0200)
source/BootManager.py

index 32d7ba8..5270c6c 100755 (executable)
@@ -6,8 +6,9 @@
 # Copyright (c) 2004-2006 The Trustees of Princeton University
 # All rights reserved.
 
 # Copyright (c) 2004-2006 The Trustees of Princeton University
 # All rights reserved.
 
+import sys, os
+import traceback
 import string
 import string
-import sys, os, traceback
 import time
 import gzip
 
 import time
 import gzip
 
@@ -109,6 +110,12 @@ class log:
         """
         self.LogEntry( str, 0, 1 )
     
         """
         self.LogEntry( str, 0, 1 )
     
+    def print_stack (self):
+        """
+        dump current stack in log
+        """
+        self.write ( traceback.format_exc() )
+
     # bm log uploading is available back again, as of nodeconfig-5.0-2
     def Upload( self, extra_file=None ):
         """
     # bm log uploading is available back again, as of nodeconfig-5.0-2
     def Upload( self, extra_file=None ):
         """
@@ -332,18 +339,20 @@ class BootManager:
 
         except KeyError, e:
             self.LOG.write( "\n\nKeyError while running: %s\n" % str(e) )
 
         except KeyError, e:
             self.LOG.write( "\n\nKeyError while running: %s\n" % str(e) )
+            self.LOG.print_stack ()
         except BootManagerException, e:
             self.LOG.write( "\n\nException while running: %s\n" % str(e) )
         except BootManagerException, e:
             self.LOG.write( "\n\nException while running: %s\n" % str(e) )
+            self.LOG.print_stack ()
         except BootManagerAuthenticationException, e:
             self.LOG.write( "\n\nFailed to Authenticate Node: %s\n" % str(e) )
         except BootManagerAuthenticationException, e:
             self.LOG.write( "\n\nFailed to Authenticate Node: %s\n" % str(e) )
+            self.LOG.print_stack ()
             # sets /tmp/CANCEL_BOOT flag
             StartDebug.Run(self.VARS, self.LOG )
             # Return immediately b/c any other calls to API will fail
             return success
         except:
             self.LOG.write( "\n\nImplementation Error\n")
             # sets /tmp/CANCEL_BOOT flag
             StartDebug.Run(self.VARS, self.LOG )
             # Return immediately b/c any other calls to API will fail
             return success
         except:
             self.LOG.write( "\n\nImplementation Error\n")
-            traceback.print_exc(file=self.LOG.OutputFile)
-            traceback.print_exc()
+            self.LOG.print_stack ()
 
         if not success:
             try:
 
         if not success:
             try: