Kaynağa Gözat

timestamp & other fixes

[SVN r24064]
Aleksey Gurtovoy 22 yıl önce
ebeveyn
işleme
824518da88

+ 23 - 21
tools/regression/xsl_reports/runner/collect_and_upload_logs.py

@@ -8,6 +8,8 @@
 import xml.sax.saxutils
 import xml.sax.saxutils
 import zipfile
 import zipfile
 import ftplib
 import ftplib
+import time
+import stat
 
 
 import os.path
 import os.path
 import string
 import string
@@ -41,12 +43,6 @@ def collect_test_logs( input_dirs, test_results_writer ):
         os.path.walk( input_dir, process_test_log_files, test_results_writer )
         os.path.walk( input_dir, process_test_log_files, test_results_writer )
 
 
 
 
-def upload_to_sourceforge( user, tag, results_file ):
-    upload_dir = 'regression-logs/incoming/%s/' % tag
-    utils.log( 'Uploading test results file "%s" into "%s" [connecting as %s]...' % ( results_file, upload_dir, user ) )
-    
-    utils.sourceforge.upload( results_file, upload_dir, user )
-
 def upload_to_ftp( tag, results_file ):
 def upload_to_ftp( tag, results_file ):
     ftp_site = 'fx.meta-comm.com'
     ftp_site = 'fx.meta-comm.com'
     site_path = '/boost-regression'
     site_path = '/boost-regression'
@@ -96,17 +92,24 @@ def collect_logs(
     test_results_writer = open( test_results_file, "w" )
     test_results_writer = open( test_results_file, "w" )
     utils.log( 'Collecting test logs into "%s"...' % test_results_file )
     utils.log( 'Collecting test logs into "%s"...' % test_results_file )
     
     
+    if not os.path.exists( timestamp ):
+        t = time.gmtime()
+        utils.log( 'Warning: timestamp file "%s" does not exist' )
+        utils.log( 'Using current UTC time (%s)' % ( timestamp, t ) )
+    else:
+        t = time.gmtime( os.stat( timestamp ).st_mtime )
+    
     results_xml = xml.sax.saxutils.XMLGenerator( test_results_writer )
     results_xml = xml.sax.saxutils.XMLGenerator( test_results_writer )
     results_xml.startDocument()
     results_xml.startDocument()
     results_xml.startElement( 
     results_xml.startElement( 
-          "test-run"
+          'test-run'
         , { 
         , { 
-              "tag":        tag
-            , "platform":   platform
-            , "runner":     runner_id
-            , "timestamp":  timestamp 
-            , "source":     source
-            , "run-type":   run_type
+              'tag':        tag
+            , 'platform':   platform
+            , 'runner':     runner_id
+            , 'timestamp':  time.strftime( '%a, %d %b %Y %H:%M:%S +0000', t )     
+            , 'source':     source
+            , 'run-type':   run_type
             }
             }
         )
         )
     
     
@@ -127,10 +130,7 @@ def collect_logs(
 
 
 def upload_logs( runner_id, tag, user ):
 def upload_logs( runner_id, tag, user ):
     logs_archive = '%s.zip' % runner_id
     logs_archive = '%s.zip' % runner_id
-    if user is None or user == 'anonymous':
-        upload_to_ftp( tag, logs_archive )
-    else:
-        upload_to_sourceforge( user, tag, logs_archive )
+    upload_to_ftp( tag, logs_archive )
 
 
 
 
 def collect_and_upload_logs( 
 def collect_and_upload_logs( 
@@ -173,10 +173,11 @@ def accept_args( args ):
     options = {
     options = {
           '--tag' :         'CVS-HEAD'
           '--tag' :         'CVS-HEAD'
         , '--platform' :    sys.platform
         , '--platform' :    sys.platform
-        , '--user' :        None
         , '--comment' :     None
         , '--comment' :     None
-        , '--source' :      ''
-        , '--run-type' :    ''
+        , '--timestamp' :   'timestamp'
+        , '--user' :        None
+        , '--source' :      'unknown'
+        , '--run-type' :    'unknown'
         }
         }
     
     
     utils.accept_args( args_spec, args, options, usage )
     utils.accept_args( args_spec, args, options, usage )
@@ -199,7 +200,8 @@ def usage():
     print    '''
     print    '''
 \t--locate-root   directory to to scan for 'test_log.xml' files
 \t--locate-root   directory to to scan for 'test_log.xml' files
 \t--runner        runner ID (e.g. 'Metacomm')
 \t--runner        runner ID (e.g. 'Metacomm')
-\t--timestamp     timestamp of the run
+\t--timestamp     path to a file which modification time will be used 
+\t                as a timestamp of the run ('timestamp' by default)
 \t--comment       an HTML comment file to be inserted in the reports
 \t--comment       an HTML comment file to be inserted in the reports
 \t                ('comment.html' by default)
 \t                ('comment.html' by default)
 \t--tag           the tag for the results ('CVS-HEAD' by default)
 \t--tag           the tag for the results ('CVS-HEAD' by default)

+ 43 - 27
tools/regression/xsl_reports/runner/regression.py

@@ -27,7 +27,7 @@ install_log = os.path.join( regression_results, 'bjam_install.log' )
 boost_root = os.path.join( regression_root, 'boost' )
 boost_root = os.path.join( regression_root, 'boost' )
 xsl_reports_dir = os.path.join( boost_root, 'tools', 'regression', 'xsl_reports' )
 xsl_reports_dir = os.path.join( boost_root, 'tools', 'regression', 'xsl_reports' )
 comment_path = os.path.join( regression_root, 'comment.html' )
 comment_path = os.path.join( regression_root, 'comment.html' )
-timestamp_path = os.path.join( boost_root, 'boost' )
+timestamp_path = os.path.join( regression_root, 'timestamp' )
 
 
 cvs_command_line = 'cvs -z9 %(command)s'
 cvs_command_line = 'cvs -z9 %(command)s'
 cvs_ext_command_line = 'cvs -d:ext:%(user)s@cvs.sourceforge.net:/cvsroot/boost -z9 %(command)s'
 cvs_ext_command_line = 'cvs -d:ext:%(user)s@cvs.sourceforge.net:/cvsroot/boost -z9 %(command)s'
@@ -137,12 +137,6 @@ def download_boost_tarball( destination, tag, proxy ):
     return tarball_path
     return tarball_path
 
 
 
 
-def time_to_string( t ):
-    return time.strftime( 
-              "%a, %d %b %Y %H:%M:%S +0000"
-              , time.gmtime( t )
-              )
-
 def unpack_tarball( tarball_path, destination ):
 def unpack_tarball( tarball_path, destination ):
     log( 'Looking for old unpacked archives...' )
     log( 'Looking for old unpacked archives...' )
     old_boost_dirs =  glob.glob( os.path.join( destination, 'boost-*' ) )
     old_boost_dirs =  glob.glob( os.path.join( destination, 'boost-*' ) )
@@ -172,12 +166,6 @@ def unpack_tarball( tarball_path, destination ):
     log( 'Renaming "%s" into "%s"' % ( boost_dir, boost_root ) )
     log( 'Renaming "%s" into "%s"' % ( boost_dir, boost_root ) )
     os.rename( boost_dir, boost_root )
     os.rename( boost_dir, boost_root )
 
 
-    # utime doesn't work on directories in Win32, but for that same 
-    # reason we don't need to adjust the timestamp -- it's already 
-    # current
-    if not sys.platform == 'win32':
-        os.utime( timestamp_path, ( time.time(), time.time() ) )
-
 
 
 def cvs_command( user, command ):
 def cvs_command( user, command ):
     if user is None:
     if user is None:
@@ -221,8 +209,21 @@ def cvs_update( user, tag, args ):
        )
        )
 
 
 
 
+def format_time( t ):
+    return time.strftime( 
+          '%a, %d %b %Y %H:%M:%S +0000'
+        , t
+        )    
+
+def timestamp():
+    return format_time( 
+          time.gmtime( os.stat( timestamp_path ).st_mtime )
+        )    
+
+
 def get_source( user, tag, proxy, args, **unused ):
 def get_source( user, tag, proxy, args, **unused ):
-    log( "Getting sources ..." )
+    open( timestamp_path, 'w' ).close()
+    log( 'Getting sources (%s)...' % timestamp() )
 
 
     if user is not None:
     if user is not None:
         cvs_checkout( user, tag, args )
         cvs_checkout( user, tag, args )
@@ -233,7 +234,8 @@ def get_source( user, tag, proxy, args, **unused ):
 
 
 def update_source( user, tag, proxy, args, **unused ):
 def update_source( user, tag, proxy, args, **unused ):
     if user is not None or os.path.exists( os.path.join( boost_root, 'CVS' ) ):
     if user is not None or os.path.exists( os.path.join( boost_root, 'CVS' ) ):
-        log( 'Updating sources from CVS...' )
+        open( timestamp_path, 'w' ).close()
+        log( 'Updating sources from CVS (%s)...' % timestamp() )
         cvs_update( user, tag, args )
         cvs_update( user, tag, args )
     else:
     else:
         get_source( user, tag, proxy, args )
         get_source( user, tag, proxy, args )
@@ -418,10 +420,13 @@ def collect_logs(
     if incremental: run_type = 'incremental'
     if incremental: run_type = 'incremental'
     else:           run_type = 'full'
     else:           run_type = 'full'
 
 
-    source = ''
-    if user is None:          source = 'tarball'
-    elif user == 'anonymous': source = 'anonymous CVS'
-    else:                     source = 'CVS'
+    source = 'tarball'
+    cvs_root_file = os.path.join( boost_root, 'CVS', 'root' )
+    if os.path.exists( cvs_root_file ):
+        if string.split( open( cvs_root_file ).readline(), '@' )[0] == ':pserver:anonymous':
+            source = 'anonymous CVS'
+        else:
+            source = 'CVS'
    
    
     from runner import collect_logs
     from runner import collect_logs
     collect_logs( 
     collect_logs( 
@@ -430,10 +435,7 @@ def collect_logs(
         , tag
         , tag
         , platform
         , platform
         , comment_path
         , comment_path
-        , time.strftime( 
-              "%a, %d %b %Y %H:%M:%S +0000"
-            , time.gmtime( os.stat( timestamp_path ).st_mtime )
-            )
+        , timestamp_path
         , user
         , user
         , source
         , source
         , run_type
         , run_type
@@ -465,7 +467,12 @@ def regression(
         ):
         ):
 
 
     try:
     try:
-        mail_subject = "Boost regression for %s on %s \n" % ( tag, string.split(socket.gethostname(), '.')[0] )
+        mail_subject = 'Boost regression for %s on %s ' % ( tag, string.split(socket.gethostname(), '.')[0] )
+        start_time = time.localtime()
+        if mail:
+            log( 'Sending start notification to "%s"' % mail )
+            utils.send_mail( mail, mail_subject + ' started at %s.' % format_time( start_time ) )
+
         if incremental:
         if incremental:
             update_source( user, tag, proxy, [] )
             update_source( user, tag, proxy, [] )
             setup( comment, [] )
             setup( comment, [] )
@@ -480,12 +487,21 @@ def regression(
 
 
         if mail:
         if mail:
             log( 'Sending report to "%s"' % mail )
             log( 'Sending report to "%s"' % mail )
-            utils.send_mail( mail, mail_subject + ' completed successfully.' )
+            end_time = time.localtime()
+            utils.send_mail( 
+                  mail
+                , mail_subject + ' completed successfully at %s.' % format_time( end_time )
+                )
     except:
     except:
         if mail:
         if mail:
             log( 'Sending report to "%s"' % mail )
             log( 'Sending report to "%s"' % mail )
-            msg = regression_log + [ "" ] + apply( traceback.format_exception, sys.exc_info() ) 
-            utils.send_mail( mail, mail_subject + ' failed.', '\n'.join( msg ) )
+            msg = regression_log + [ '' ] + apply( traceback.format_exception, sys.exc_info() ) 
+            end_time = time.localtime()
+            utils.send_mail( 
+                  mail
+                , mail_subject + ' failed at %s.' % format_time( end_time )
+                , '\n'.join( msg )
+                )
         raise
         raise
 
 
 
 

粤ICP备19079148号