gump-general mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From aj...@apache.org
Subject svn commit: rev 36300 - in gump/trunk/python/gump: core document/xdocs model mysql notify process repository results run runner stats stats/mysql syndication test timing utils
Date Thu, 12 Aug 2004 21:12:13 GMT
Author: ajack
Date: Thu Aug 12 14:12:12 2004
New Revision: 36300

Added:
   gump/trunk/python/gump/stats/statsdb.py
Modified:
   gump/trunk/python/gump/core/config.py
   gump/trunk/python/gump/core/gumpinit.py
   gump/trunk/python/gump/document/xdocs/documenter.py
   gump/trunk/python/gump/document/xdocs/xdoc.py
   gump/trunk/python/gump/model/module.py
   gump/trunk/python/gump/model/object.py
   gump/trunk/python/gump/model/project.py
   gump/trunk/python/gump/model/stats.py
   gump/trunk/python/gump/model/workspace.py
   gump/trunk/python/gump/mysql/databaser.py
   gump/trunk/python/gump/notify/notification.py
   gump/trunk/python/gump/process/command.py
   gump/trunk/python/gump/process/launcher.py
   gump/trunk/python/gump/repository/artifact.py
   gump/trunk/python/gump/results/resulter.py
   gump/trunk/python/gump/run/gumpenv.py
   gump/trunk/python/gump/run/gumprun.py
   gump/trunk/python/gump/runner/runner.py
   gump/trunk/python/gump/stats/mysql/statsdb.py
   gump/trunk/python/gump/syndication/rss.py
   gump/trunk/python/gump/test/__init__.py
   gump/trunk/python/gump/test/diagram.py
   gump/trunk/python/gump/test/pyunit.py
   gump/trunk/python/gump/test/resolving.py
   gump/trunk/python/gump/test/stats.py
   gump/trunk/python/gump/test/timing.py
   gump/trunk/python/gump/test/utils.py
   gump/trunk/python/gump/test/xref.py
   gump/trunk/python/gump/timing/keeper.py
   gump/trunk/python/gump/utils/__init__.py
   gump/trunk/python/gump/utils/http.py
   gump/trunk/python/gump/utils/tasks.py
   gump/trunk/python/gump/utils/timing.py
   gump/trunk/python/gump/utils/work.py
Log:
Trying to fix what I broke...
Propagated datetime throughout Gump (replacing timestamp)

Modified: gump/trunk/python/gump/core/config.py
==============================================================================
--- gump/trunk/python/gump/core/config.py	(original)
+++ gump/trunk/python/gump/core/config.py	Thu Aug 12 14:12:12 2004
@@ -21,6 +21,7 @@
 
 import socket
 import time
+import datetime
 import os
 import sys
 import logging
@@ -49,7 +50,28 @@
   """returns the path absolutized relative to the base gump dir"""
 
   return os.path.abspath(os.path.join(basedir or dir.base,path))
-
+    
+class setting:    
+    """Configuration of hardcoded settings"""
+    
+    VERSION='2.1.0-alpha-0002'
+    
+    WS_VERSION="0.4"
+    WS_MINIMUM_VERSION="0.3"
+    
+    DATETIME_FORMAT='%S%M%H%d%m%Y'
+    DATE_FORMAT='%d%m%Y'
+    
+    DATE_PRESENTATION_FORMAT='%a, %d %b %Y'
+    
+    DATETIME_PRESENTATION_FORMAT='%a, %d %b %Y %H:%M:%S (%Z)'
+    TIME_PRESENTATION_FORMAT='%H:%M:%S (%Z)'
+    
+    UTC_DATETIME_PRESENTATION_FORMAT='%a, %d %b %Y %H:%M:%S (UTC)'
+    UTC_TIME_PRESENTATION_FORMAT='%H:%M:%S (UTC)'
+    
+    TIMEOUT=60*60 # 60 minutes (in seconds)
+    
 class default:
     """Configuration of default settings"""
     
@@ -59,8 +81,12 @@
     workspace  = os.path.abspath('%s/%s.xml' % (dir.base, gumphost))
     globalws   = os.path.abspath('%s/%s' % (dir.base, 'global-workspace.xml'))
     merge      = os.path.abspath('%s/%s' % (dir.work, 'merge.xml'))
-    date       = time.strftime('%Y%m%d')
-    datetime   = time.strftime('%Y%m%d %H:%M:%S')
+    
+    # Note, these can be updated by gumpinit
+    timestamp    = time.time()
+    datetime     = datetime.datetime.fromtimestamp(timestamp)
+    datetime_str = datetime.strftime(setting.DATETIME_FORMAT)
+    date_str     = datetime.strftime(setting.DATE_FORMAT)
     
     logLevel   = logging.INFO # logging.DEBUG
     classpath = (os.getenv('CLASSPATH') or '').split(os.pathsep)  
@@ -86,21 +112,7 @@
         classpathSeparator=';'
         shellQuote='"'
         shellEscape='\\'
-    
-class setting:    
-    """Configuration of hardcoded settings"""
-    
-    version='2.1.0-alpha-0002'
-    
-    ws_version="0.4"
-    ws_minimum_version="0.3"
-    
-    datetimeformat='%a, %d %b %Y %H:%M:%S (%Z)'
-    timeformat='%H:%M:%S (%Z)'
-    utcdatetimeformat='%a, %d %b %Y %H:%M:%S (UTC)'
-    utctimeformat='%H:%M:%S (UTC)'
-    
-    timeout=60*60 # 60 minutes (in seconds)
+
     
 class switch:
     """Configuration of switches """   

Modified: gump/trunk/python/gump/core/gumpinit.py
==============================================================================
--- gump/trunk/python/gump/core/gumpinit.py	(original)
+++ gump/trunk/python/gump/core/gumpinit.py	Thu Aug 12 14:12:12 2004
@@ -53,17 +53,16 @@
     # If a .timestamp exists, use it.
     timestamp=os.path.join(dir.base,'.timestamp')
     if os.path.exists(timestamp):
-        default.time = os.path.getmtime(timestamp)
+        default.timestamp = os.path.getmtime(timestamp)
     else:
-        default.time = time.time()
-
-    # Generate for local and date...
-    default.ltime=time.localtime(default.time)
-    default.date = time.strftime('%Y%m%d',default.ltime)
-    default.datetime = time.strftime('%Y%m%d %H:%M:%S',default.ltime)
+        default.timestamp = time.time()
+    # Import this timestamp
+    default.datetime   = datetime.datetime.fromtimestamp(default.timestamp)
+    default.datetime_s = default.datetime.strftime(setting.DATETIME_FORMAT)
+    default.date_s     = default.datetime.strftime(setting.DATE_FORMAT)
+    default.datetime_sp= default.datetime.strftime(setting.DATETIME_PRESENTATION_FORMAT)
+    default.date_sp    = default.datetime.strftime(setting.DATE_PRESENTATION_FORMAT)
     
-    default.datetimeObject = datetime.datetime.fromtimestamp(default.time)
-
     
 if __name__ == '__main__':
     gumpinit()

Modified: gump/trunk/python/gump/document/xdocs/documenter.py
==============================================================================
--- gump/trunk/python/gump/document/xdocs/documenter.py	(original)
+++ gump/trunk/python/gump/document/xdocs/documenter.py	Thu Aug 12 14:12:12 2004
@@ -307,7 +307,7 @@
         definitionTable=definitionSection.createTable()
         definitionTable.createEntry('Gump Run GUID', self.run.getRunGuid())
         definitionTable.createEntry('Gump Run (Hex) GUID', self.run.getRunHexGuid())
-        definitionTable.createEntry('Gump Version', setting.version)
+        definitionTable.createEntry('Gump Version', setting.VERSION)
         
         rssSyndRow=definitionTable.createRow()
         rssSyndRow.createData().createStrong('Syndication')
@@ -320,12 +320,12 @@
         
         dtSection=definitionSection.createSection('Dates/Times')            
         dtTable=dtSection.createTable()        
-        dtTable.createEntry('@@DATE@@', str(default.date))
-        dtTable.createEntry('Start Date/Time (UTC)', self.workspace.getStartDateTimeUtc())
-        dtTable.createEntry('End Date/Time (UTC)', self.workspace.getEndDateTimeUtc())
-        dtTable.createEntry('Timezone', self.workspace.timezone)
-        dtTable.createEntry('Start Date/Time', self.workspace.getStartDateTime())
-        dtTable.createEntry('End Date/Time', self.workspace.getEndDateTime())
+        dtTable.createEntry('@@DATE@@', default.date_s)
+        dtTable.createEntry('Start Date/Time (UTC)', self.run.getStart().getUtc())
+        dtTable.createEntry('End Date/Time (UTC)', self.run.getEnd().getUtc())
+        dtTable.createEntry('Timezone', self.run.getEnvironment().getTimezone())
+        dtTable.createEntry('Start Date/Time', self.run.getStart().getLocal())
+        dtTable.createEntry('End Date/Time', self.run.getEnd().getLocal())
 
         pythonSection=definitionSection.createSection('Python Information')            
         pythonTable=pythonSection.createTable()
@@ -519,13 +519,13 @@
                 self.workspace.getDomAttributeValue('version'))
         if not self.workspace.hasDomAttribute('version') \
             or not self.workspace.getDomAttributeValue('version') \
-                    == setting.ws_version:
+                    == setting.WS_VERSION:
             definitionTable.createEntry('Gump Preferred Workspace Version', 
-                                        setting.ws_version)
-        definitionTable.createEntry('@@DATE@@', str(default.date))
-        definitionTable.createEntry('Start Date/Time (UTC)', self.workspace.getStartDateTimeUtc())
-        definitionTable.createEntry('Start Date/Time', self.workspace.getStartDateTime())
-        definitionTable.createEntry('Timezone', self.workspace.timezone)
+                                        setting.WS_VERSION)
+        definitionTable.createEntry('@@DATE@@', default.date_s)
+        definitionTable.createEntry('Start Date/Time (UTC)', self.run.getStart().getUtc())
+        definitionTable.createEntry('Start Date/Time', self.run.getStart().getLocal())
+        definitionTable.createEntry('Timezone', self.run.getEnvironment().getTimezone())
    
             
         rssSyndRow=definitionTable.createRow()
@@ -676,9 +676,8 @@
                 serverRow.createData('Not Available')
                 
             if server.hasResults():
-                serverRow.createData(server.getResults().getStartDateTime())
-                serverRow.createData(server.getResults().getStartDateTimeUtc())
-                serverRow.createData(server.getResults().getEndDateTimeUtc())
+                serverRow.createData(server.getResults().getStart().getLocal())
+                serverRow.createData(server.getResults().getEnd().getLocal())
                 serverRow.createData(server.getResults().getTimezoneOffset())
             else:
                 serverRow.createData('N/A')
@@ -740,7 +739,7 @@
         
             document.createWarning("""This Gump run is currently in progress.
             It started at %s. As of this moment (%s), %s modules have been updated, and %s projects built.""" \
-                % (self.workspace.getStartDateTime(), time.strftime('%H:%M:%S'), modules, projects ))
+                % (self.run.getStart().getLocal(), time.strftime('%H:%M:%S'), modules, projects ))
                 
             #document.createNote("""Only projects with significant information 
             #(e.g a recent change of state, a failure, etc.) are listed at runtime.""")
@@ -748,8 +747,8 @@
         else:
             document.createNote("""This Gump run is complete. 
             It started at %s and ended at %s.""" 
-                % ( self.workspace.getStartDateTime(),
-                    self.workspace.getEndDateTime()))
+                % ( self.run.getStart().getLocal(),
+                    self.run.getEnd().getLocal()))
                     
         if not self.gumpSet.isFull():
                 self.documentPartial(document)
@@ -775,7 +774,11 @@
                 
                 moduleRow.createData(module.getPositionIndex())    
             
-                startData=moduleRow.createData(secsToTime(module.getStartSecs()))          
+                if module.hasStart():
+                    startData=moduleRow.createData(module.getStart().getLocal())          
+                else:                    
+                    startData=moduleRow.createData('-')       
+                    
                 self.setStyleFromState(startData,module.getStatePair())
                         
                 self.insertLink(module,self.workspace,moduleRow.createData())   
@@ -819,7 +822,10 @@
             
             projectRow.createData(project.getPositionIndex())    
             
-            projectRow.createData(secsToTime(project.getStartSecs()))  
+            if project.hasStart():
+                projectRow.createData(project.getStart().getLocal())  
+            else:
+                projectRow.createData('-')  
                       
             self.insertLink(project,self.workspace,projectRow.createData())   
             self.insertStateIcon(project,self.workspace,projectRow.createData())      
@@ -2295,7 +2301,7 @@
             workRow.setStyle(stateName(work.state).upper())
                 
             if isinstance(work,TimedWorkItem):      
-                workRow.createData(secsToDateTime(work.result.start_time))
+                workRow.createData(work.result.start.isoformat())
                 workRow.createData(secsToElapsedTimeString(work.getElapsedSecs()))
             else:
                 workRow.createData('N/A')
@@ -2363,8 +2369,8 @@
                 workList.createEntry("Termination Signal: ", str(work.result.signal))
             workList.createEntry("Exit Code: ", str(work.result.exit_code))
                                 
-            workList.createEntry("Start Time: ", secsToDateTime(work.result.start_time))
-            workList.createEntry("End Time: ", secsToDateTime(work.result.end_time))
+            workList.createEntry("Start Time: ", work.result.start.isoformat())
+            workList.createEntry("End Time: ", work.result.end.isoformat())
             e = secsToElapsedTimeString(work.getElapsedSecs())
             if e : workList.createEntry("Elapsed Time: ", e)
                    
@@ -3023,10 +3029,15 @@
             if not self.gumpSet.inModuleSequence(module): continue   
             if module.isPackaged(): continue 
             updRow=updTable.createRow()            
-            self.insertLink( module, stats, updRow.createData())                
-            updRow.createData(secsToDateTime(module.getLastModified()))
-            updRow.createData(	\
-                getGeneralSinceDescription(module.getLastModified()))
+            self.insertLink( module, stats, updRow.createData())
+            if module.hasLastModified():
+                updRow.createData(module.getLastModified().isoformat())
+                updRow.createData(	\
+                    getGeneralSinceDescription(module.getLastModified()))
+            else:
+                updRow.createData('-')
+                updRow.createData('-')
+                
             modules+=1                    
         if not modules: updTable.createLine('None')
             

Modified: gump/trunk/python/gump/document/xdocs/xdoc.py
==============================================================================
--- gump/trunk/python/gump/document/xdocs/xdoc.py	(original)
+++ gump/trunk/python/gump/document/xdocs/xdoc.py	Thu Aug 12 14:12:12 2004
@@ -784,7 +784,7 @@
         else:
             from gump.core.config import default
             self.context.writeLine('<p align="right">Last Updated: %s.<A TARGET="_new" HREF="http://python.org"><img border ="0" align="right" src="%s/images/PythonPowered.gif" alt="Python Logo"/></A></p>' \
-                                    % (default.datetime, self.rootpath)) 
+                                    % (default.datetime_sp, self.rootpath)) 
             self.context.writeLine('</html>')            
         self.close()                  
             

Modified: gump/trunk/python/gump/model/module.py
==============================================================================
--- gump/trunk/python/gump/model/module.py	(original)
+++ gump/trunk/python/gump/model/module.py	Thu Aug 12 14:12:12 2004
@@ -547,6 +547,9 @@
             
         return float(historicalOdds)/float(historicalOddses)
         
+    def hasLastModified(self):
+        return self.getStats().hasLastModified()                
+    
     def getLastModified(self):
         return self.getStats().getLastModified()                
     
@@ -666,8 +669,12 @@
         Statistics.__init__(self,moduleName)    
         self.lastModified=None
         
+    def hasLastModified(self):
+        if self.lastModified: return True
+        return False
+        
     def getLastModified(self):
-        return (self.lastModified)
+        return self.lastModified
         
     def getKeyBase(self):
         return 'module:'+ self.name
@@ -682,4 +689,4 @@
         # Track code updates/changes
         # 
         if module.isModified():
-            self.lastModified=default.datetimeObject
\ No newline at end of file
+            self.lastModified=default.datetime
\ No newline at end of file

Modified: gump/trunk/python/gump/model/object.py
==============================================================================
--- gump/trunk/python/gump/model/object.py	(original)
+++ gump/trunk/python/gump/model/object.py	Thu Aug 12 14:12:12 2004
@@ -173,7 +173,7 @@
         if not value: return value
         
         # Right now just one supported
-        return value.replace('@@DATE@@',default.date)
+        return value.replace('@@DATE@@',default.date_s)
     
         
     def hasDomChild(self,name):

Modified: gump/trunk/python/gump/model/project.py
==============================================================================
--- gump/trunk/python/gump/model/project.py	(original)
+++ gump/trunk/python/gump/model/project.py	Thu Aug 12 14:12:12 2004
@@ -423,7 +423,7 @@
                         if newId.endswith('.jar'):
                             newId=newId[:-4]
                         # Strip off -@@DATE@@
-                        datePostfix='-' + str(default.date)
+                        datePostfix='-' + str(default.date_s)
                         if newId.endswith(datePostfix):
                             reduction=-1 * len(datePostfix)
                             newId=newId[:reduction]

Modified: gump/trunk/python/gump/model/stats.py
==============================================================================
--- gump/trunk/python/gump/model/stats.py	(original)
+++ gump/trunk/python/gump/model/stats.py	Thu Aug 12 14:12:12 2004
@@ -66,9 +66,6 @@
     def getTotalRuns(self):
         return (self.successes+self.failures+self.prereqs)
         
-    def getLastModified(self):
-        return (self.lastModified)
-        
     def nameKey(self):
         return self.getKeyBase() + '-name'
         
@@ -106,7 +103,7 @@
         if statable.isSuccess():
 
             self.successes += 1
-            self.last = default.datetimeObject
+            self.last = default.datetime
             
             # A big event...
             if not self.first:
@@ -135,7 +132,7 @@
             self.sequenceInState += 1            
         else:
             self.previousState=lastCurrentState  
-            self.startOfState = default.datetimeObject       
+            self.startOfState = default.datetime       
             self.sequenceInState = 1
            
     def dump(self, indent=0, output=sys.stdout):

Modified: gump/trunk/python/gump/model/workspace.py
==============================================================================
--- gump/trunk/python/gump/model/workspace.py	(original)
+++ gump/trunk/python/gump/model/workspace.py	Thu Aug 12 14:12:12 2004
@@ -98,64 +98,10 @@
                     
         # Database Informaton
         self.dbInfo=None
-        
-        # Set times
-        self.initializeTimes()
 
         # Where the merged XML was put
         self.mergeFile=None
-        
-    def initializeTimes(self):
-        # Store timezone
-        self.timezone=str(time.tzname)    
-        
-        self.startDateTimeUtc=''
-        self.startDateTime=''
-                                 
-        self.endDateTimeUtc=''
-        self.endDateTime=''
-                
-    # :TODO: Move these to run, like much dynamic stuff on W/S
-
-    def setStartTime(self):                
-                
-        # :TODO: Ensure no clock ticks between these two,
-        # i.e. make one.
-        self.startDateTimeUtc=time.strftime(setting.utcdatetimeformat, \
-                                            time.gmtime())
-        self.startDateTime=time.strftime(setting.datetimeformat, \
-                                            time.localtime())
-                                                    
-        self.endDateTimeUtc=''
-        self.endDateTime=''
-        
-    def setEndTime(self):
-        
-        # Don't do more than once.
-        if self.endDateTimeUtc and self.endDateTime: return
-            
-        
-        # :TODO: Ensure no clock ticks between these two,
-        # i.e. make one.
-        self.endDateTimeUtc=time.strftime(setting.utcdatetimeformat, \
-                                            time.gmtime())
-        self.endDateTime=time.strftime(setting.datetimeformat, \
-                                            time.localtime())                                            
-        
-    def getTimezone(self):
-        return self.timezone
-        
-    def getStartDateTime(self):
-        return self.startDateTime
-        
-    def getStartDateTimeUtc(self):
-        return self.startDateTimeUtc
-        
-    def getEndDateTime(self):
-        return self.endDateTime
-        
-    def getEndDateTimeUtc(self):
-        return self.endDateTimeUtc
+ 
         
     def getChildren(self):
         return self.getModules() 
@@ -414,7 +360,7 @@
     def setDatedDirectories(self,date=None):
         
         # This build date
-        if not date: date = default.date
+        if not date: date = default.date_s
             
         # Construct tmp on demand
         self.tmpdir=os.path.join(self.tmpdir,date)            

Modified: gump/trunk/python/gump/mysql/databaser.py
==============================================================================
--- gump/trunk/python/gump/mysql/databaser.py	(original)
+++ gump/trunk/python/gump/mysql/databaser.py	Thu Aug 12 14:12:12 2004
@@ -65,8 +65,9 @@
             if module.hasCause():
                 settings['cause']="'" + module.getCause().getName() + "'"
                 
-            #settings['start']=
-            #settings['end']=
+            if module.hasTimes():
+                settings['start']="'" + module.getStart().getTimestamp().strftime('%Y-%m-%d %H:%M:%S') + "'"
+                settings['end']="'" + module.getEnd().getTimestamp().strftime('%Y-%m-%d %H:%M:%S') + "'"
             
             helper.insert('module_run',settings)
             
@@ -94,8 +95,9 @@
             if project.hasCause():
                 settings['cause']="'" + project.getCause().getName() + "'"
                 
-            #settings['start']=
-            #settings['end']=
+            if project.hasTimes():
+                settings['start']="'" + project.getStart().getTimestamp().strftime('%Y-%m-%d %H:%M:%S') + "'"
+                settings['end']="'" + project.getEnd().getTimestamp().strftime('%Y-%m-%d %H:%M:%S') + "'"
             
             helper.insert('project_run',settings)
             

Modified: gump/trunk/python/gump/notify/notification.py
==============================================================================
--- gump/trunk/python/gump/notify/notification.py	(original)
+++ gump/trunk/python/gump/notify/notification.py	Thu Aug 12 14:12:12 2004
@@ -263,8 +263,8 @@
         if id:
             stream.write('Gump E-mail Identifier (within run) #%s.\n' % id )
         stream.write('Produced by Gump %s.\n[Run (%s, %s)]' %	\
-                        (	setting.version, 
-                            default.datetime, 
+                        (	setting.VERSION, 
+                            default.datetime_s, 
                             self.run.getRunGuid() ))
         stream.write('\n')
 

Modified: gump/trunk/python/gump/process/command.py
==============================================================================
--- gump/trunk/python/gump/process/command.py	(original)
+++ gump/trunk/python/gump/process/command.py	Thu Aug 12 14:12:12 2004
@@ -163,7 +163,7 @@
       
 class Cmd:
     """Command Line (executable plus parameters)"""
-    def __init__(self,command,name=None,cwd=None,env=None,timeout=setting.timeout):
+    def __init__(self,command,name=None,cwd=None,env=None,timeout=setting.TIMEOUT):
         self.cmdpath=command
         self.name=name
         if not self.name:
@@ -241,8 +241,8 @@
         self.exit_code=-1
         
         # To calculate elapsed
-        self.start_time=None
-        self.end_time=None
+        self.start=None
+        self.end=None
         
     def overview(self,indent):
         overview = indent+"State: " + states[self.state]
@@ -278,17 +278,17 @@
         return self.output
         
     def hasTimes(self):
-        if self.start_time and self.end_time: return 1
+        if self.start and self.end: return 1
         return 0
         
-    def getStartSecs(self):
-        return self.start_time
+    def getStart(self):
+        return self.start
         
-    def getEndSecs(self):
-        return self.end_time
+    def getEnd(self):
+        return self.end
         
     def getElapsedSecs(self):
-        return int(round(self.end_time-self.start_time,0))        
+        return deltaToSecs(self.end-self.start)        
         
     def dump(self,indent):
         print self.overview(indent)

Modified: gump/trunk/python/gump/process/launcher.py
==============================================================================
--- gump/trunk/python/gump/process/launcher.py	(original)
+++ gump/trunk/python/gump/process/launcher.py	Thu Aug 12 14:12:12 2004
@@ -46,7 +46,7 @@
    	"""	
     
     outputFile=None
-    start_time=time.time()
+    start=datetime.datetime.now()
     try:
       try:          
  
@@ -148,9 +148,9 @@
               os.remove(outputFile)
         
       # Keep time information
-      end_time=time.time()
-      result.start_time=start_time
-      result.end_time=end_time 
+      end=datetime.datetime.now()
+      result.start=start
+      result.end=end 
 	  
     return result
     

Modified: gump/trunk/python/gump/repository/artifact.py
==============================================================================
--- gump/trunk/python/gump/repository/artifact.py	(original)
+++ gump/trunk/python/gump/repository/artifact.py	Thu Aug 12 14:12:12 2004
@@ -84,7 +84,7 @@
         #
         if id:
             (artifactRoot, artifactExtn) = os.path.splitext(artifactName)
-            artifactName=id + '-gump-' + str(default.date) + artifactExtn
+            artifactName=id + '-gump-' + default.date.strftime(setting.DATE_FORMAT) + artifactExtn
         
         newArtifact=os.path.join(cdir,artifactName)
         

Modified: gump/trunk/python/gump/results/resulter.py
==============================================================================
--- gump/trunk/python/gump/results/resulter.py	(original)
+++ gump/trunk/python/gump/results/resulter.py	Thu Aug 12 14:12:12 2004
@@ -183,14 +183,12 @@
         workspaceResults = WorkspaceResult(self.workspace.getName())
         
         # :TODO: Find nicer way to transfer (or just reference)
-        workspaceResults.startDateTime=self.workspace.getStartDateTime()
-        workspaceResults.startDateTimeUtc=self.workspace.getStartDateTimeUtc()
-        workspaceResults.endDateTime=self.workspace.getEndDateTime()
-        workspaceResults.endDateTimeUtc=self.workspace.getEndDateTimeUtc()
+        workspaceResults.startDateTime=self.run.getStartDateTime()
+        workspaceResults.startDateTimeUtc=self.run.getStartDateTimeUtc()
+        workspaceResults.endDateTime=self.run.getEndDateTime()
+        workspaceResults.endDateTimeUtc=self.run.getEndDateTimeUtc()
         
-        # :TODO: Timezones and such are on env, not workspace [move them]
-        workspaceResults.timezone=self.workspace.getTimezone()
-
+        workspaceResults.timezone=self.run.getEnvironment().getTimezone()
         workspaceResults.timezoneOffset=self.run.getEnvironment().getTimezoneOffset()
     
         # For all modules...

Modified: gump/trunk/python/gump/run/gumpenv.py
==============================================================================
--- gump/trunk/python/gump/run/gumpenv.py	(original)
+++ gump/trunk/python/gump/run/gumpenv.py	Thu Aug 12 14:12:12 2004
@@ -89,7 +89,8 @@
         # DEPOT_HOME
         self.depotHome = None
         
-        # Offset from UTC
+        # Timezone and offset from UTC
+        self.timezone=time.timezone
         self.timezoneOffset=TZ
         
     def checkEnvironment(self,exitOnError=False):
@@ -310,6 +311,9 @@
         
     def getJavaCommand(self):
         return self.javaCommand
+        
+    def getTimezone(self):
+        return self.timezone
         
     def getTimezoneOffset(self):
         return self.timezoneOffset

Modified: gump/trunk/python/gump/run/gumprun.py
==============================================================================
--- gump/trunk/python/gump/run/gumprun.py	(original)
+++ gump/trunk/python/gump/run/gumprun.py	Thu Aug 12 14:12:12 2004
@@ -59,7 +59,7 @@
 ###############################################################################
 
 
-class GumpRun(gump.utils.work.Workable,gump.utils.note.Annotatable,Stateful):
+class GumpRun(gump.utils.timing.Timeable,gump.utils.work.Workable,gump.utils.note.Annotatable,Stateful):
     """
     The container for all information for this run
     """
@@ -68,6 +68,7 @@
         gump.utils.work.Workable.__init__(self)
         gump.utils.note.Annotatable.__init__(self)
         Stateful.__init__(self)
+        gump.utils.timing.Timeable.__init__(self, workspace.getName())
         
         # The workspace being worked upon
         self.workspace=workspace
@@ -95,10 +96,10 @@
         import md5
         import socket        
         m=md5.new()
-        self.guid = socket.getfqdn()  + ':' + workspace.getName() + ':' + default.datetime
+        self.guid = socket.getfqdn()  + ':' + workspace.getName() + ':' + default.datetime_s
         m.update(self.guid)
         self.hexguid=m.hexdigest().upper()     
-        log.debug('Run GUID [' + `self.guid` + '] using [' + `self.hexguid` + ']')    
+        log.info('Run GUID [' + `self.guid` + '] using [' + `self.hexguid` + ']')    
         
         # Actor Queue
         self.actors=list()
@@ -194,6 +195,7 @@
     		Fire off a typed request.
     	"""
         self._dispatchRequest(RunRequest(self, type))
+   
         
 class RunSpecific:
     """

Modified: gump/trunk/python/gump/runner/runner.py
==============================================================================
--- gump/trunk/python/gump/runner/runner.py	(original)
+++ gump/trunk/python/gump/runner/runner.py	Thu Aug 12 14:12:12 2004
@@ -86,14 +86,14 @@
             workspace.setDatedDirectories()     
                     
         # Check the workspace
-        if not workspace.getVersion() >= setting.ws_version:
-            message='Workspace version ['+str(workspace.getVersion())+'] below preferred [' + setting.ws_version + ']'
+        if not workspace.getVersion() >= setting.WS_VERSION:
+            message='Workspace version ['+str(workspace.getVersion())+'] below preferred [' + setting.WS_VERSION + ']'
             workspace.addWarning(message)
             log.warn(message)   
             
         # Check the workspace
-        if not workspace.getVersion() >= setting.ws_minimum_version:
-            message='Workspace version ['+str(workspace.getVersion())+'] below minimum [' + setting.ws_minimum_version + ']'
+        if not workspace.getVersion() >= setting.WS_MINIMUM_VERSION:
+            message='Workspace version ['+str(workspace.getVersion())+'] below minimum [' + setting.WS_MINIMUM_VERSION + ']'
             workspace.addError(message)
             log.error(message)   
             

Modified: gump/trunk/python/gump/stats/mysql/statsdb.py
==============================================================================
--- gump/trunk/python/gump/stats/mysql/statsdb.py	(original)
+++ gump/trunk/python/gump/stats/mysql/statsdb.py	Thu Aug 12 14:12:12 2004
@@ -136,9 +136,9 @@
                     stats.lastModified=value
                 else:
                     if not value == '0000-00-00 00:00:00':
-                        setattr(stats,attr,
-                                datetime.datetime.fromtimestamp(time.mktime(time.strptime(value,
-                                                                                '%Y-%m-%d %H:%M:%S'))))                    
+                        stats.lastModified=datetime.datetime.fromtimestamp( \
+                                                time.mktime(time.strptime(value,
+                                                                          '%Y-%m-%d %H:%M:%S')))                 
         except IndexError:
             pass
         return stats
@@ -193,7 +193,7 @@
                     
                     
                     if column in StatisticsDB.DATES:   
-                        print "GET ATTR : " + `type(getattr(stats,attr))`                      
+                        #print "GET ATTR : " + `type(getattr(stats,attr))`                      
                         if isinstance(value,datetime.datetime):
                             setattr(stats,attr,value)
                         else:

Added: gump/trunk/python/gump/stats/statsdb.py
==============================================================================
--- (empty file)
+++ gump/trunk/python/gump/stats/statsdb.py	Thu Aug 12 14:12:12 2004
@@ -0,0 +1,109 @@
+#!/usr/bin/env python
+# Copyright 2003-2004 The Apache Software Foundation
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+# 
+#     http://www.apache.org/licenses/LICENSE-2.0
+# 
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+"""
+    Statistics gathering/manipulation
+"""
+
+import time
+import os
+import sys
+import logging
+import anydbm
+
+from gump import log
+from gump.core.config import *
+from gump.model.project import Project, ProjectStatistics
+from gump.model.module import Module, ModuleStatistics
+from gump.model.repository import Repository, RepositoryStatistics
+from gump.model.workspace import Workspace, WorkspaceStatistics
+from gump.model.state import *
+
+from gump.shared.comparator import *
+  
+class StatisticsDB:
+    """
+    	Statistics Database Abstract Interface
+    """
+
+    def __init__(self,dbdir=None,name=None):
+        pass
+ 
+                
+    # Workspace
+    def getWorkspaceStats(self,workspaceName):
+        stats=WorkspaceStatistics(workspaceName)
+        self.getBaseStats(stats)
+        return stats
+        
+    def putWorkspaceStats(self,stats):
+        self.putBaseStats(stats)
+
+    def delWorkspaceStats(self,stats):
+        self.delBaseStats(stats)          
+        
+        
+    # Project
+    
+    def getProjectStats(self,projectName):
+        stats=ProjectStatistics(projectName)        
+        self.getBaseStats(stats)
+        return stats
+                
+    def putProjectStats(self,stats):
+        self.putBaseStats(stats)
+
+    def delProjectStats(self,stats):
+        self.delBaseStats(stats)          
+
+    # Repository
+    
+    def getRepositoryStats(self,projectName):
+        stats=RepositoryStatistics(projectName)        
+        self.getBaseStats(stats)
+        return stats
+                
+    def putRepositoryStats(self,stats):
+        self.putBaseStats(stats)
+
+    def delRepositoryStats(self,stats):
+        self.delBaseStats(stats)          
+
+    # Module
+    
+    def getModuleStats(self,moduleName):
+        stats=ModuleStatistics(moduleName)        
+        self.getBaseStats(stats)
+        stats.lastModified=self.getDate(stats.lastModifiedKey())
+        return stats
+                
+    def putModuleStats(self,stats):
+        self.putBaseStats(stats)
+        self.putDate(stats.lastModifiedKey(), stats.lastModified)
+
+    def delModuleStats(self,stats):
+        self.delBaseStats(stats)
+        try:
+            del self.db[stats.lastModifiedKey()]
+        except:
+            """ Hopefully means it wasn't there... """                
+  
+    def sync(self):
+        """
+        Try to sync the DB to disk (assuming it has a sync, which
+        some implementations do not).
+        """
+        if hasattr(self.db, 'sync'):
+            self.db.sync()
+          
\ No newline at end of file

Modified: gump/trunk/python/gump/syndication/rss.py
==============================================================================
--- gump/trunk/python/gump/syndication/rss.py	(original)
+++ gump/trunk/python/gump/syndication/rss.py	Thu Aug 12 14:12:12 2004
@@ -136,7 +136,7 @@
         
         self.rssStream.write('  <language>en-us</language>\n')
         self.rssStream.write('  <copyright>Copyright 2003, Apache Software Foundation</copyright>\n')
-        self.rssStream.write(('  <generator>Jakarta Gump : %s</generator>\n') % (escape(setting.version)))
+        self.rssStream.write(('  <generator>Jakarta Gump : %s</generator>\n') % (escape(setting.VERSION)))
         self.rssStream.write('  <webMaster>general@gump.apache.org</webMaster>\n')
         self.rssStream.write('  <docs>http://blogs.law.harvard.edu/tech/rss</docs>\n')
         self.rssStream.write('  <category domain="http://www.apache.org/namespaces">Gump</category>\n')
@@ -153,7 +153,7 @@
 
     <sy:updateFrequency>1</sy:updateFrequency>
     <sy:updatePeriod>daily</sy:updatePeriod>
-""" % setting.version)
+""" % setting.VERSION)
             
     def endChannel(self):
         self.rssStream.write('  </channel>\n')

Modified: gump/trunk/python/gump/test/__init__.py
==============================================================================
--- gump/trunk/python/gump/test/__init__.py	(original)
+++ gump/trunk/python/gump/test/__init__.py	Thu Aug 12 14:12:12 2004
@@ -30,7 +30,7 @@
 from gump.model.state import *
 from gump.model.workspace import Workspace
 
-from gump.stats.statsdb import StatisticsDB
+from gump.stats.statistician import Statistician
 from gump.utils.tools import listDirectoryToFileHolder
 from gump.utils.work import *
 
@@ -39,27 +39,13 @@
     return gump.run.gumprun.GumpRun(workspace,'*',getConfiguredOptions())
     
 def getWorkedTestRun(workspaceXml=None):
-    workspace=getWorkedTestWorkspace(workspaceXml)
-    return gump.run.gumprun.GumpRun(workspace,'*',getConfiguredOptions())
+    workspace=getTestWorkspace(workspaceXml)
     
-def getConfiguredOptions():
-    options=gump.run.options.GumpRunOptions()
-    from gump.document.xdocs.resolver import XDocResolver
-    options.setResolver(XDocResolver('./test/bogus','http://bogus.org/'))
-    return options
-
-def getTestWorkspace(xml=None):
-    if not xml: xml='gump/test/resources/full1/workspace.xml'    
-    #print "Workspace File: " + str(xml)    
-    workspace = WorkspaceLoader(False).load(xml)
-    return workspace
+    run = gump.run.gumprun.GumpRun(workspace,'*',getConfiguredOptions())
     
-def getWorkedTestWorkspace(xml=None):
-    workspace=getTestWorkspace(xml)
-       
     # Load statistics for this workspace
-    db=StatisticsDB(gump.core.config.dir.test,'test.db')  
-    db.loadStatistics(workspace)
+    stats=Statistician(run)  
+    stats.loadStatistics()
 
     # Some file items...
     listDirectoryToFileHolder(workspace,workspace.getBaseDirectory())        
@@ -103,7 +89,19 @@
                 project.changeState(STATE_FAILED)
             else:
                 project.changeState(STATE_SUCCESS)
+    
+    return run
+    
+def getConfiguredOptions():
+    options=gump.run.options.GumpRunOptions()
+    from gump.document.xdocs.resolver import XDocResolver
+    options.setResolver(XDocResolver('./test/bogus','http://bogus.org/'))
+    return options
 
+def getTestWorkspace(xml=None):
+    if not xml: xml='gump/test/resources/full1/workspace.xml'    
+    #print "Workspace File: " + str(xml)    
+    workspace = WorkspaceLoader(False).load(xml)
     return workspace
     
 def createTestWorkspace():

Modified: gump/trunk/python/gump/test/diagram.py
==============================================================================
--- gump/trunk/python/gump/test/diagram.py	(original)
+++ gump/trunk/python/gump/test/diagram.py	Thu Aug 12 14:12:12 2004
@@ -22,7 +22,7 @@
 from gump.svg.drawing import *
 from gump.svg.scale import ScaleDiagram
 from gump.svg.depdiag import DependencyDiagram
-from gump.test import getWorkedTestWorkspace
+from gump.test import getWorkedTestRun
 from gump.test.pyunit import UnitTestSuite
 
 import StringIO
@@ -33,10 +33,14 @@
         
     def suiteSetUp(self):
         #
-        # Load a decent Workspace
+        # Load a decent Run/Workspace
         #
-        self.workspace=getWorkedTestWorkspace() 
+        self.run=getWorkedTestRun()  
+        self.assertNotNone('Needed a run', self.run)
+        self.workspace=self.run.getWorkspace()          
         self.assertNotNone('Needed a workspace', self.workspace)
+        
+        
         self.project5=self.workspace.getProject('project5')
         
     def testDependencyDiagramGeneration(self):

Modified: gump/trunk/python/gump/test/pyunit.py
==============================================================================
--- gump/trunk/python/gump/test/pyunit.py	(original)
+++ gump/trunk/python/gump/test/pyunit.py	Thu Aug 12 14:12:12 2004
@@ -117,6 +117,9 @@
         self.assertNonZero(message,object)
         self.assertString(message,object)
         
+    def failed(self,message):
+        self.raiseIssue(['Failed', message])    
+        
 class Problem:
     def __init__(self,suite,test,error=None):
         self.suite=suite

Modified: gump/trunk/python/gump/test/resolving.py
==============================================================================
--- gump/trunk/python/gump/test/resolving.py	(original)
+++ gump/trunk/python/gump/test/resolving.py	Thu Aug 12 14:12:12 2004
@@ -37,9 +37,11 @@
         
     def suiteSetUp(self):
         #
-        # Load a decent Workspace
+        # Load a decent Run/Workspace
         #
-        self.workspace=getWorkedTestWorkspace()          
+        self.run=getWorkedTestRun()  
+        self.assertNotNone('Needed a run', self.run)
+        self.workspace=self.run.getWorkspace()          
         self.assertNotNone('Needed a workspace', self.workspace)
         
         self.module1=self.workspace.getModule('module1')

Modified: gump/trunk/python/gump/test/stats.py
==============================================================================
--- gump/trunk/python/gump/test/stats.py	(original)
+++ gump/trunk/python/gump/test/stats.py	Thu Aug 12 14:12:12 2004
@@ -26,7 +26,7 @@
 from gump.stats.statsdb import *
 from gump.utils import *
 from gump.utils.timing import *
-from gump.test import getWorkedTestWorkspace
+from gump.test import getWorkedTestRun
 from gump.test.pyunit import UnitTestSuite
 
 class StatsTestSuite(UnitTestSuite):
@@ -35,11 +35,14 @@
         
     def suiteSetUp(self):
         #
-        # Load a decent Workspace
+        # Load a decent Run/Workspace
         #
-        self.workspace=getWorkedTestWorkspace()          
+        self.run=getWorkedTestRun()  
+        self.assertNotNone('Needed a run', self.run)
+        self.workspace=self.run.getWorkspace()          
         self.assertNotNone('Needed a workspace', self.workspace)
         
+        
         self.repo1=self.workspace.getRepository('repository1')                  
         self.project1=self.workspace.getProject('project1')        
         self.module1=self.workspace.getModule('module1')
@@ -113,7 +116,7 @@
         # Give some padding.
         lastModified -= (60*60*7)
         
-        rough=getGeneralDifferenceDescription(default.time, lastModified)
+        rough=getGeneralDifferenceDescription(default.datetime, lastModified)
         self.assertNonZeroString('Date Diff String', rough)
         self.assertNotSubstring('Date Diff String', 'year', rough)        
      

Modified: gump/trunk/python/gump/test/timing.py
==============================================================================
--- gump/trunk/python/gump/test/timing.py	(original)
+++ gump/trunk/python/gump/test/timing.py	Thu Aug 12 14:12:12 2004
@@ -16,6 +16,7 @@
 """
     Timing Utilities Testing
 """
+import time
 
 from gump.utils import *
 from gump.utils.timing import *
@@ -26,19 +27,25 @@
         UnitTestSuite.__init__(self)
         
     def suiteSetUp(self):
-        self.now=default.time
+        self.nowTimestamp=time.time()
+        self.now=datetime.datetime.utcfromtimestamp(self.nowTimestamp)
         
     def testDateTimeUtils(self):
-        oneHourBefore=self.now - (60*60)
-        twoHoursBefore=self.now - (60*60*2)
-        oneDayBefore=self.now - (60*60*24)
-        twoDaysBefore=self.now - (60*60*24*2)
-        oneWeekBefore=self.now - (60*60*24*7)
-        twoWeeksBefore=self.now - (60*60*24*7*2)
-        oneMonthBefore=self.now - (60*60*24*31)
-        twoMonthsBefore=self.now - (60*60*24*31*2)
-        oneYearBefore=self.now - (60*60*24*365)
-        twoYearsBefore=self.now - (60*60*24*365*2)
+        oneHourBefore=datetime.datetime.utcfromtimestamp(self.nowTimestamp - (60*60))
+        twoHoursBefore=datetime.datetime.utcfromtimestamp(self.nowTimestamp - (60*60*2))
+        oneDayBefore=datetime.datetime.utcfromtimestamp(self.nowTimestamp - (60*60*24))
+        twoDaysBefore=datetime.datetime.utcfromtimestamp(self.nowTimestamp - (60*60*24*2))
+        oneWeekBefore=datetime.datetime.utcfromtimestamp(self.nowTimestamp - (60*60*24*7))
+        twoWeeksBefore=datetime.datetime.utcfromtimestamp(self.nowTimestamp - (60*60*24*7*2))
+        oneMonthBefore=datetime.datetime.utcfromtimestamp(self.nowTimestamp - (60*60*24*31))
+        twoMonthsBefore=datetime.datetime.utcfromtimestamp(self.nowTimestamp - (60*60*24*31*2))
+        oneYearBefore=datetime.datetime.utcfromtimestamp(self.nowTimestamp - (60*60*24*365))
+        twoYearsBefore=datetime.datetime.utcfromtimestamp(self.nowTimestamp - (60*60*24*365*2))
+        
+        try:
+            getGeneralDifferenceDescription(oneHourBefore, self.now)
+            self.failed('Expect exception on reverse time')
+        except: pass
         
         rough=getGeneralDifferenceDescription(self.now, oneHourBefore)
         self.assertInString('Date Diff String', '1 hour', rough)
@@ -71,10 +78,9 @@
         self.assertInString('Date Diff String', '2 years', rough)
         
     def testRandomStuff(self):
-        # :TODO: Clean this up, just moved it here so as not to loose it.
+        # :TODO: Clean this up, just moved it here so as not to lose it.
         secsToElapsedTimeTriple(1340)
         secsToElapsedTimeString(1340)
-        secsToTime(1340)
         elapsedTimeTripleToString(secsToElapsedTimeTriple(1340))
   
     def testTimeStampSet(self):
@@ -89,13 +95,13 @@
         
         range1=TimeStampRange('Range1')
         time.sleep(5)
-        range1.setEndTime()
+        range1.setEnd()
         range1.setExternal(True)
         set.registerRange(range1)
         
         range2=TimeStampRange('Range2')
         time.sleep(5)
-        range2.setEndTime()
+        range2.setEnd()
         range2.setExternal(False)
         set.registerRange(range2)
         

Modified: gump/trunk/python/gump/test/utils.py
==============================================================================
--- gump/trunk/python/gump/test/utils.py	(original)
+++ gump/trunk/python/gump/test/utils.py	Thu Aug 12 14:12:12 2004
@@ -30,7 +30,7 @@
         UnitTestSuite.__init__(self)
         
     def suiteSetUp(self):
-        self.now=default.time
+        self.now=default.datetime
     
     def testWrap(self):
         

Modified: gump/trunk/python/gump/test/xref.py
==============================================================================
--- gump/trunk/python/gump/test/xref.py	(original)
+++ gump/trunk/python/gump/test/xref.py	Thu Aug 12 14:12:12 2004
@@ -27,7 +27,7 @@
 from gump.loader.loader import WorkspaceLoader
 from gump.guru.xref import XRefGuru
 from gump.utils import *
-from gump.test import getWorkedTestWorkspace
+from gump.test import getWorkedTestRun
 from gump.test.pyunit import UnitTestSuite
 
 class XRefTestSuite(UnitTestSuite):
@@ -36,11 +36,12 @@
         
     def suiteSetUp(self):
         #
-        # Load a decent Workspace
+        # Load a decent Run/Workspace
         #
-        self.workspace=getWorkedTestWorkspace() 
-        self.assertNotNone('Needed a workspace', self.workspace)    
-        
+        self.run=getWorkedTestRun()  
+        self.assertNotNone('Needed a run', self.run)
+        self.workspace=self.run.getWorkspace()          
+        self.assertNotNone('Needed a workspace', self.workspace)
         
     def testXRefGuru(self):
         gug=XRefGuru(self.workspace)

Modified: gump/trunk/python/gump/timing/keeper.py
==============================================================================
--- gump/trunk/python/gump/timing/keeper.py	(original)
+++ gump/trunk/python/gump/timing/keeper.py	Thu Aug 12 14:12:12 2004
@@ -35,7 +35,7 @@
         	run.      
         """
         if isinstance(event,gump.run.gumprun.InitializeRunEvent):
-            self.run.getWorkspace().setStartTime()
+            self.run.setStart()
         elif isinstance(event,gump.run.gumprun.FinalizeRunEvent):  
-            self.run.getWorkspace().setEndTime()
+            self.run.setEnd()
             

Modified: gump/trunk/python/gump/utils/__init__.py
==============================================================================
--- gump/trunk/python/gump/utils/__init__.py	(original)
+++ gump/trunk/python/gump/utils/__init__.py	Thu Aug 12 14:12:12 2004
@@ -144,7 +144,7 @@
     printSeparator()
     print
     print "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"
-    print "Apache Python Gump (" + setting.version + "), a multi-project builder."
+    print "Apache Python Gump (" + setting.VERSION + "), a multi-project builder."
     print  
     print "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"
     print

Modified: gump/trunk/python/gump/utils/http.py
==============================================================================
--- gump/trunk/python/gump/utils/http.py	(original)
+++ gump/trunk/python/gump/utils/http.py	Thu Aug 12 14:12:12 2004
@@ -41,7 +41,7 @@
 #
 class GumpUrlOpener(urllib.FancyURLopener):
     def __init__(self, *args):
-        self.version = "Apache-Gump/"+setting.version
+        self.version = "Apache-Gump/"+setting.VERSION
         urllib.FancyURLopener.__init__(self, *args)
 
 urllib._urlopener = GumpUrlOpener()

Modified: gump/trunk/python/gump/utils/tasks.py
==============================================================================
--- gump/trunk/python/gump/utils/tasks.py	(original)
+++ gump/trunk/python/gump/utils/tasks.py	Thu Aug 12 14:12:12 2004
@@ -92,7 +92,7 @@
         self.timeRange=TimeStampRange(self.name)
         
     def workCompleted(self):
-        self.timeRange.setEndTime()
+        self.timeRange.setEnd()
 
     def setFailed(self,failed):
         self.failed=failed

Modified: gump/trunk/python/gump/utils/timing.py
==============================================================================
--- gump/trunk/python/gump/utils/timing.py	(original)
+++ gump/trunk/python/gump/utils/timing.py	Thu Aug 12 14:12:12 2004
@@ -23,12 +23,29 @@
 
 import os
 import os.path
+
 import time
+import datetime
 
 from gump.utils import getIndent
 from gump.core.config import default, setting
 
-def secsToElapsedTimeTriple(secs):   
+ZERO_DELTA=datetime.timedelta(seconds=0)
+
+def deltaToSecs(delta):
+    """
+    	Convert a delta into it's total seconds
+    """
+    if delta < ZERO_DELTA:
+        raise RuntimeError, "Can not cope with backwards deltas"
+        
+    # Convert days to seconds, and add extra seconds.
+    return int(round(((delta.days * 24 * 3600) + delta.seconds),0))
+    
+def deltaToElapsedTimeTriple(delta):  
+        
+    secs = deltaToSecs(delta)
+    
     # Extract Hours
     if secs > 3600:
         hours    =    int(secs / 3600)
@@ -49,7 +66,10 @@
     return (hours, mins, secs)
     
 def secsToElapsedTimeString(secs):
-    return elapsedTimeTripleToString(secsToElapsedTimeTriple(secs))           
+    return deltaToElapsedTimeString(datetime.timedelta(seconds=secs))
+     
+def deltaToElapsedTimeString(delta):
+    return elapsedTimeTripleToString(deltaToElapsedTimeTriple(delta))           
     
 def elapsedTimeTripleToString(elapsed,noTimeText=None):
     elapsedString=''
@@ -76,30 +96,40 @@
     
     return elapsedString    
     
-def secsToDateTime(secs):
-    if not secs: return '-'
-    return time.strftime(setting.datetimeformat, time.localtime(secs))    
-    
-# See note on secsToDate               
-def secsToTime(secs):
-    if not secs: return '-'
-    return time.strftime(setting.timeformat, time.localtime(secs))                    
+def toDateTime(datetime):
+    if not datetime: return '-'
+    return datetime.strftime(setting.DATETIME_PRESENTATION_FORMAT)    
+    
+# See note on toDate               
+def toTime(datetime):
+    if not datetime: return '-'
+    return datetime.strftime(setting.TIME_PRESENTATION_FORMAT)                    
                 
 def getGeneralSinceDescription(secs, since=None):
-    if not since: since = default.time
+    if not since: since = default.datetime
     return getGeneralDifferenceDescription( since, secs )
             
-def getGeneralDifferenceDescription(newerSecs,olderSecs):
-    if not 0 >= olderSecs and not olderSecs >= newerSecs:
+def getGeneralDifferenceDescription(newer,older):
+    if not newer: return '-'
+    if not older: return '-'
+    
+    """
+    Get a presentation format for a time difference,
+    	e.g 1 day or 1 hour, etc.
+    """
+    if older < newer:
+        
+        diffSecs = deltaToSecs(newer - older)
+        
         diffString='~ '
-        diffSecs=newerSecs - olderSecs
+        diff=newer - older
         
-        diffSecs    =    int(diffSecs)
-        diffMins    =    int(diffSecs / 60)
+        diffSecs     =    int(diffSecs)
+        diffMins     =    int(diffSecs / 60)
         diffHours    =    int(diffSecs / 3600)
-        diffDays    =    int(diffHours / 24)
+        diffDays     =    int(diffHours / 24)
         diffWeeks    =    int(diffDays / 7)
-        diffMonths    =    int(diffDays / 31)
+        diffMonths   =    int(diffDays / 31)
         diffYears    =    int(diffDays / 365)
         
         if diffYears:
@@ -124,47 +154,46 @@
             diffString += str(diffSecs) + ' sec'
             if diffSecs > 1: diffString += 's'
         else:
-            diffString = 'This run: ' + secsToTime(newerSecs)
-    elif olderSecs == newerSecs:
-        diffString = 'This run: ' + secsToTime(newerSecs)
+            diffString = 'This run: ' + toTime(newer)
+    elif older == newer:
+        diffString = 'This run: ' + toTime(newer)
     else:
         diffString = 'N/A'
     
     return diffString
     
-
 class TimeStamp:       
     def __init__(self,name,stamp=None):
-        self.name=name       
-        
+        self.name=name               
         if not stamp:
-            stamp=time.time()
-        self.stampTime=stamp       
+            stamp=datetime.datetime.now()
+        self.timestamp=stamp       
         
     # Representations:
-    def getUtc():
+    def getUtc(self):
         if hasattr(self,'utc'): return self.utc 
-        self.utc=time.strftime(setting.utcdatetimeformat, time.gmtime(self.stampTime))
+        self.utc=self.timestamp.strftime(setting.UTC_DATETIME_PRESENTATION_FORMAT)
         return self.utc
         
     # Representations:
-    def getLocal():
+    def getLocal(self):
         if hasattr(self,'local'): return self.local 
-        self.local=time.strftime(setting.datetimeformat, time.localtime(self.stampTime))
+        self.local=self.timestamp.strftime(setting.UTC_DATETIME_PRESENTATION_FORMAT)
         return self.local
+    
+    def getTimestamp(self):
+        return self.timestamp
      
     def __nonzero__(self):
-        return self.stampTime > 0
+        if self.timestamp: return True
+        return False
         
     def __str__(self):
         return 'TimeStamp: '+self.name+' : '+ \
-                secsToDateTime(self.stampTime) 
+                toDateTime(self.timestamp) 
                 
     def __cmp__(self,other):
-        return int(self.stampTime - other.stampTime) 
-        
-    def getTime(self):
-        return self.stampTime
+        return int(self.timestamp - other.timestamp) 
         
 class TimeStampRange:       
     def __init__(self,name,start=None,end=None,external=False):
@@ -187,23 +216,30 @@
         return 'TimeStamp: '+self.name+' : '+ \
                 secsToElapsedTimeString(self.getElapsedSecs()) 
                 
-    def setEndTime(self,end=None):             
+    def setEnd(self,end=None):             
         if not end:
             end=TimeStamp('End of ' + self.name)    
         self.endTimeStamp=end
         
-    def getStartTimeStamp(self):
+    def hasStart(self):
+        if self.startTimeStamp: return True
+        return False
+        
+    def getStart(self):
         return self.startTimeStamp
          
-    def getEndTimeStamp(self):
+    def getEnd(self):
         return self.endTimeStamp
         
-    def hasTimes(self):
-        if self.startTimeStamp and self.endTimeStamp: return True
+    def hasEnd(self):
+        if self.endTimeStamp: return True
         return False
         
+    def hasTimes(self):
+        return self.hasStart() and self.hasEnd()
+        
     def getElapsedSecs(self):
-        return self.endTimeStamp.getTime() - self.startTimeStamp.getTime()
+        return deltaToSecs(self.endTimeStamp.getTimestamp() - self.startTimeStamp.getTimestamp())
         
     def getElapsedTimeString(self):
         return secsToElapsedTimeString(self.getElapsedSecs()) 
@@ -215,10 +251,8 @@
         return self.external
 
 class TimeStampSet(list):
-    """
-    
-        A named collection of timestamps    
-            
+    """   
+        A named collection of timestamps                
     """
     def __init__(self,name,start=None):
         list.__init__(self)
@@ -236,8 +270,8 @@
         
     def registerRange(self,range):  
         # :TODO: don't assume stored in time order
-        self.endTimeStamp=range.getEndTimeStamp()         
-        return self.store(range)
+        self.endTimeStamp=range.getEnd()         
+        return self._store(range)
             
     def stamp(self,sname):
         """
@@ -245,15 +279,15 @@
         """
         # Stamp (end calculated)...       
         stamp=TimeStamp(sname)  
-        return self.store(stamp)
+        return self._store(stamp)
         
-    def store(self,stamp):
+    def _store(self,stamp):
         # Store for posterity
         self.append(stamp) 
         return stamp
         
     def getElapsedSecs(self):
-        return self.endTimeStamp.getTime() - self.startTimeStamp.getTime()
+        return self.endTimeStamp.getTimestamp() - self.startTimeStamp.getTimestamp()
         
     def getTotalTimes(self):
         
@@ -272,6 +306,20 @@
         elapsed=self.getElapsedSecs()
         
         return (elapsed, accounted, external)
+       
+    # :TODO: Move these to run, like much dynamic stuff on W/S
+
+    def setStart(self,comment='Start'):                                
+        self.stamp(comment)
+        
+    def setEnd(self,comment='End'):                             
+        self.stamp(comment)                                   
+        
+    def getStart(self):
+        return self.startTimeStamp
+        
+    def getEnd(self):
+        return self.endTimeStamp
         
     def importTimes(self,otherSet):
         for entry in otherSet:
@@ -290,7 +338,6 @@
             output.write(str(entry))
             output.write('\n')
             
-            
 class TimeStampSetSet(list):   
     def __init__(self):
         list.__init__(self)
@@ -311,4 +358,30 @@
             
         return (elapsed, accounted, external)
         
+class Timeable:
+    def __init__(self,name):        
+        if not name:
+            name = self.__class__.__name__
+        self.times=TimeStampSet(name)
+        
+    def getTimes(self):
+        return self.times
+        
+    def hasStart(self):
+        return self.times.hasStart()
+        
+    def setStart(self,comment=None):
+        self.times.setStart(comment)
+        
+    def getStart(self):
+        return self.times.getStart()
+    
+    def hasEnd(self):
+        return self.times.hasEnd()
+        
+    def setEnd(self,comment=None):
+        self.times.setEnd(comment)
+        
+    def getEnd(self):
+        return self.times.getEnd()
     

Modified: gump/trunk/python/gump/utils/work.py
==============================================================================
--- gump/trunk/python/gump/utils/work.py	(original)
+++ gump/trunk/python/gump/utils/work.py	Thu Aug 12 14:12:12 2004
@@ -86,18 +86,24 @@
 
 class TimedWorkItem(WorkItem):
     """ Unit of Work w/ times """
-    def __init__(self,name,type,state,startSecs,endSecs,message=''):
+    def __init__(self,name,type,state,start,end,message=''):
         WorkItem.__init__(self,name,type,state,message)
         self.timerange=TimeStampRange(name,
-                                TimeStamp(name,startSecs),
-                                TimeStamp(name,endSecs),
+                                TimeStamp(name,start),
+                                TimeStamp(name,end),
                                 True)
     
-    def getStartSecs(self):   
-        return self.timerange.getStartTimeStamp().getTime()
+    def hasStart(self):
+        return self.timerange.hasStart()
         
-    def getEndSecs(self):   
-        return self.timerange.getEndTimeStamp().getTime()
+    def getStart(self):   
+        return self.timerange.getStart()
+        
+    def hasEnd(self):
+        return self.timerange.hasEnd()
+        
+    def getEnd(self):   
+        return self.timerange.getEnd()
         
     def getElapsedSecs(self):   
         if self.timerange.hasTimes():
@@ -118,8 +124,8 @@
         
     def clone(self):
         return TimedWorkItem(self.name,self.type,self.state,
-                                self.timerange.getStartTime(),
-                                self.timerange.getEndTime(),
+                                self.timerange.getStart().getTimestamp(),
+                                self.timerange.getEnd().getTimestamp(),
                                 self.message)
        
        
@@ -135,10 +141,11 @@
     """ Unit of Work"""
     def __init__(self,type,command,result=None,message=''):
         if not result: result=gump.process.command.CmdResult(command)
-        TimedWorkItem.__init__(self,command.name,type,\
-                commandStateToWorkState(result.state),	\
-                result.getStartSecs(),	\
-                result.getEndSecs(),message)
+        TimedWorkItem.__init__(self,command.name,type,
+                commandStateToWorkState(result.state),
+                result.getStart(),
+                result.getEnd(),
+                message)
         self.command=command
         self.result=result
                 
@@ -212,23 +219,35 @@
         
         # Let this item know its owner
         item.setOwner(self.getOwner())
+        
+    def hasStart(self):
+        if self.getStart(): return True
+        return False
     
-    def getStartSecs(self):
-        startSecs=0
+    def getStart(self):
+        start=None
         for item in self:
             if isinstance(item,TimedWorkItem): 
-                if not startSecs or item.getStartSecs() < startSecs:
-                    startSecs=item.getStartSecs()
-        if startSecs: return startSecs
+                if not start or item.getStart() < start:
+                    start=item.getStart()
+        return start
     
-    def getEndSecs(self):
-        endSecs=0
+    def hasEnd(self):
+        if self.getEnd(): return True
+        return False
+            
+    def getEnd(self):
+        end=None
         for item in self:
             if isinstance(item,TimedWorkItem): 
-                if not endSecs or item.getEndSecs() < endSecs:
-                    endSecs=item.getEndSecs()
-        if endSecs: return endSecs
+                if not end or item.getEnd() > end:
+                    end=item.getEnd()
+        return end
     
+    def hasTimes(self):
+        if self.getStart() and self.getEnd(): return True
+        return False
+        
     def getElapsedSecs(self):
         elapsedSecs=0
         for item in self:
@@ -262,13 +281,22 @@
         	
     def okToPerformWork(self):
         return self.isUnset() or self.isSuccess()        
-               
-    def getStartSecs(self):
-        return self.worklist.getStartSecs()   
+    
+    def hasStart(self):
+        return self.worklist.hasStart()
+          
+    def getStart(self):
+        return self.worklist.getStart()   
           
-    def getEndSecs(self):
-        return self.worklist.getEndSecs()       
+    def hasEnd(self):
+        return self.worklist.hasStart()
+          
+    def getEnd(self):
+        return self.worklist.getEnd()       
                
+    def hasTimes(self):
+        return self.worklist.hasTimes()
+        
     def getElapsedSecs(self):
         return self.worklist.getElapsedSecs()
         

---------------------------------------------------------------------
To unsubscribe, e-mail: general-unsubscribe@gump.apache.org
For additional commands, e-mail: general-help@gump.apache.org


Mime
View raw message