cosmetic
[bootmanager.git] / source / BootManager.py
index 1439549..f2462bc 100755 (executable)
@@ -1,4 +1,4 @@
-#!/usr/bin/python2 -u
+#!/usr/bin/python -u
 
 # Copyright (c) 2003 Intel Corporation
 # All rights reserved.
@@ -8,8 +8,8 @@
 
 import string
 import sys, os, traceback
-from time import gmtime, strftime
-from gzip import GzipFile
+import time
+import gzip
 
 from steps import *
 from Exceptions import *
@@ -35,21 +35,24 @@ NodeRunStates = {}
 
 class log:
 
+    format="%H:%M:%S(%Z) "
+
     def __init__( self, OutputFilePath= None ):
         if OutputFilePath:
             try:
                 self.OutputFilePath= OutputFilePath
-                self.OutputFile= GzipFile( OutputFilePath, "w", 9 )
+                self.OutputFile= gzip.GzipFile( OutputFilePath, "w", 9 )
             except:
                 print( "Unable to open output file for log, continuing" )
                 self.OutputFile= None
 
     
     def LogEntry( self, str, inc_newline= 1, display_screen= 1 ):
+        now=time.strftime(log.format, time.localtime())
         if self.OutputFile:
-            self.OutputFile.write( str )
+            self.OutputFile.write( now+str )
         if display_screen:
-            sys.stdout.write( str )
+            sys.stdout.write( now+str )
             
         if inc_newline:
             if display_screen:
@@ -77,6 +80,7 @@ class log:
         """
 
         if self.OutputFile is not None:
+            self.LogEntry( "NOTE: upload logs is known to be broken (beg)")
             self.LogEntry( "Uploading logs to %s" % UPLOAD_LOG_PATH )
             
             self.OutputFile.close()
@@ -87,6 +91,7 @@ class log:
                                    GetVars = None, PostVars = None,
                                    FormData = ["log=@" + self.OutputFilePath],
                                    DoSSL = True, DoCertCheck = True)
+            self.LogEntry( "NOTE: upload logs is known to be broken (end)")
         
     
 
@@ -315,7 +320,7 @@ def main(argv):
     LOG= log( LOG_FILE )
 
     LOG.LogEntry( "BootManager started at: %s" % \
-                  strftime("%a, %d %b %Y %H:%M:%S +0000", gmtime()) )
+                  time.strftime("%a, %d %b %Y %H:%M:%S +0000", time.gmtime()) )
 
     try:
         forceState = None
@@ -332,7 +337,7 @@ def main(argv):
         
     if error:
         LOG.LogEntry( "BootManager finished at: %s" % \
-                      strftime("%a, %d %b %Y %H:%M:%S +0000", gmtime()) )
+                      time.strftime("%a, %d %b %Y %H:%M:%S +0000", time.gmtime()) )
         LOG.Upload()
         return error
 
@@ -354,7 +359,7 @@ def main(argv):
         traceback.print_exc()
 
     LOG.LogEntry( "BootManager finished at: %s" % \
-                  strftime("%a, %d %b %Y %H:%M:%S +0000", gmtime()) )
+                  time.strftime("%a, %d %b %Y %H:%M:%S +0000", time.gmtime()) )
     LOG.Upload()
 
     return error