Title: [commits] (dan) [11197] new test framework - add datestamping to log file names just like is done with current log files
Revision
11197
Author
dan
Date
2006-07-18 16:37:55 -0700 (Tue, 18 Jul 2006)

Log Message

new test framework - add datestamping to log file names just like is done with current log files

Modified Paths

Diff

Modified: trunk/chandler/tools/cats/framework/TestOutput.py (11196 => 11197)

--- trunk/chandler/tools/cats/framework/TestOutput.py	2006-07-18 23:03:12 UTC (rev 11196)
+++ trunk/chandler/tools/cats/framework/TestOutput.py	2006-07-18 23:37:55 UTC (rev 11197)
@@ -24,6 +24,8 @@
 from datetime import datetime as dtime
 import copy
 import sys
+import os.path
+import time 
 
 class datetime(dtime):
     """Class for overriding datetime's normal string method"""
@@ -73,6 +75,18 @@
            self.stdout = None
         
         if logName is not None:
+            logName = os.path.abspath(logName)
+            # Rename the last log file to timestamped version
+            try:
+                # getatime returns last mod on Unix, and creation time on Win
+                atime = os.path.getatime(logName)
+                time_stamp = time.strftime('%Y%m%d%H%M%S',
+                                           time.localtime(atime))
+                os.rename(logName, '%s.%s' % (logName, time_stamp))
+            except OSError:
+                # Most likely the file didn't exist, just ignore
+                pass            
+            
             self.f = file(logName, 'w')
         else:
             self.f = None




_______________________________________________
Commits mailing list
[email protected]
http://lists.osafoundation.org/mailman/listinfo/commits

Reply via email to