|
|
@@ -112,13 +112,23 @@ def compress_file( file_path, archive_path ):
|
|
|
utils.log( 'Done compressing "%s".' % archive_path )
|
|
|
|
|
|
|
|
|
+def read_timestamp( file ):
|
|
|
+ if not os.path.exists( file ):
|
|
|
+ result = time.gmtime()
|
|
|
+ utils.log( 'Warning: timestamp file "%s" does not exist'% file )
|
|
|
+ utils.log( 'Using current UTC time (%s)' % result )
|
|
|
+ return result
|
|
|
+
|
|
|
+ return time.gmtime( os.stat( file ).st_mtime )
|
|
|
+
|
|
|
+
|
|
|
def collect_logs(
|
|
|
results_dir
|
|
|
, runner_id
|
|
|
, tag
|
|
|
, platform
|
|
|
, comment_file
|
|
|
- , timestamp
|
|
|
+ , timestamp_file
|
|
|
, user
|
|
|
, source
|
|
|
, run_type
|
|
|
@@ -128,14 +138,7 @@ def collect_logs(
|
|
|
results_file = os.path.join( results_dir, '%s.xml' % runner_id )
|
|
|
results_writer = open( results_file, 'w' )
|
|
|
utils.log( 'Collecting test logs into "%s"...' % results_file )
|
|
|
-
|
|
|
- if not os.path.exists( timestamp ):
|
|
|
- t = time.gmtime()
|
|
|
- utils.log( 'Warning: timestamp file "%s" does not exist'% timestamp )
|
|
|
- utils.log( 'Using current UTC time (%s)' % t )
|
|
|
- else:
|
|
|
- t = time.gmtime( os.stat( timestamp ).st_mtime )
|
|
|
-
|
|
|
+
|
|
|
results_xml = xml.sax.saxutils.XMLGenerator( results_writer )
|
|
|
results_xml.startDocument()
|
|
|
results_xml.startElement(
|
|
|
@@ -144,7 +147,7 @@ def collect_logs(
|
|
|
'tag': tag
|
|
|
, 'platform': platform
|
|
|
, 'runner': runner_id
|
|
|
- , 'timestamp': time.strftime( '%Y-%m-%dT%H:%M:%SZ', t )
|
|
|
+ , 'timestamp': time.strftime( '%Y-%m-%dT%H:%M:%SZ', read_timestamp( timestamp_file ) )
|
|
|
, 'source': source
|
|
|
, 'run-type': run_type
|
|
|
}
|
|
|
@@ -172,15 +175,21 @@ def upload_logs(
|
|
|
, ftp_proxy
|
|
|
, debug_level
|
|
|
, send_bjam_log = False
|
|
|
+ , timestamp_file = None
|
|
|
, **unused
|
|
|
):
|
|
|
|
|
|
logs_archive = os.path.join( results_dir, '%s.zip' % runner_id )
|
|
|
upload_to_ftp( tag, logs_archive, ftp_proxy, debug_level )
|
|
|
if send_bjam_log:
|
|
|
- logs_archive = os.path.join( results_dir, '%s.log.zip' % runner_id )
|
|
|
- compress_file( os.path.join( results_dir, 'bjam.log' ), logs_archive )
|
|
|
- upload_to_ftp( tag, logs_archive, ftp_proxy, debug_level )
|
|
|
+ bjam_log_path = os.path.join( results_dir, 'bjam.log' )
|
|
|
+ if not timestamp_file:
|
|
|
+ timestamp_file = bjam_log_path
|
|
|
+
|
|
|
+ timestamp = time.strftime( '%Y-%m-%d-%H-%M-%S', read_timestamp( timestamp_file ) )
|
|
|
+ logs_archive = os.path.join( results_dir, '%s.%s.log.zip' % ( runner_id, timestamp ) )
|
|
|
+ compress_file( bjam_log_path, logs_archive )
|
|
|
+ upload_to_ftp( '%s/logs' % tag, logs_archive, ftp_proxy, debug_level )
|
|
|
|
|
|
|
|
|
def collect_and_upload_logs(
|
|
|
@@ -189,12 +198,13 @@ def collect_and_upload_logs(
|
|
|
, tag
|
|
|
, platform
|
|
|
, comment_file
|
|
|
- , timestamp
|
|
|
+ , timestamp_file
|
|
|
, user
|
|
|
, source
|
|
|
, run_type
|
|
|
, ftp_proxy = None
|
|
|
, debug_level = 0
|
|
|
+ , send_bjam_log = False
|
|
|
, **unused
|
|
|
):
|
|
|
|
|
|
@@ -204,13 +214,22 @@ def collect_and_upload_logs(
|
|
|
, tag
|
|
|
, platform
|
|
|
, comment_file
|
|
|
- , timestamp
|
|
|
+ , timestamp_file
|
|
|
, user
|
|
|
, source
|
|
|
, run_type
|
|
|
)
|
|
|
|
|
|
- upload_logs( results_dir, runner_id, tag, user, ftp_proxy, debug_level )
|
|
|
+ upload_logs(
|
|
|
+ results_dir
|
|
|
+ , runner_id
|
|
|
+ , tag
|
|
|
+ , user
|
|
|
+ , ftp_proxy
|
|
|
+ , debug_level
|
|
|
+ , send_bjam_log
|
|
|
+ , timestamp_file
|
|
|
+ )
|
|
|
|
|
|
|
|
|
def accept_args( args ):
|
|
|
@@ -238,8 +257,8 @@ def accept_args( args ):
|
|
|
, '--user' : None
|
|
|
, '--source' : 'CVS'
|
|
|
, '--run-type' : 'full'
|
|
|
- , '--debug-level' : 0
|
|
|
, '--ftp-proxy' : None
|
|
|
+ , '--debug-level' : 0
|
|
|
}
|
|
|
|
|
|
utils.accept_args( args_spec, args, options, usage )
|
|
|
@@ -250,7 +269,7 @@ def accept_args( args ):
|
|
|
, 'tag' : options[ '--tag' ]
|
|
|
, 'platform' : options[ '--platform']
|
|
|
, 'comment_file' : options[ '--comment' ]
|
|
|
- , 'timestamp' : options[ '--timestamp' ]
|
|
|
+ , 'timestamp_file' : options[ '--timestamp' ]
|
|
|
, 'user' : options[ '--user' ]
|
|
|
, 'source' : options[ '--source' ]
|
|
|
, 'run_type' : options[ '--run-type' ]
|