gump-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From aj...@apache.org
Subject svn commit: rev 47055 - in gump/trunk/python/gump: core document/xdocs utils
Date Wed, 22 Sep 2004 15:50:27 GMT
Author: ajack
Date: Wed Sep 22 08:50:26 2004
New Revision: 47055

Modified:
   gump/trunk/python/gump/core/config.py
   gump/trunk/python/gump/document/xdocs/documenter.py
   gump/trunk/python/gump/utils/timing.py
   gump/trunk/python/gump/utils/work.py
Log:
Added 'elapsed' time to the display.
Need to add more times everywhere.

Modified: gump/trunk/python/gump/core/config.py
==============================================================================
--- gump/trunk/python/gump/core/config.py	(original)
+++ gump/trunk/python/gump/core/config.py	Wed Sep 22 08:50:26 2004
@@ -67,8 +67,8 @@
     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 (%Z)'
-    UTC_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)
     

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	Wed Sep 22 08:50:26 2004
@@ -311,6 +311,7 @@
         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())
+        dtTable.createEntry('Elapsed Time', self.run.getElapsedTimeString())
 
         pythonSection=definitionSection.createSection('Python Information')            
         pythonTable=pythonSection.createTable()
@@ -540,7 +541,7 @@
         detailsTable.createEntry("State : ", 
                 self.workspace.getStateDescription()) 
 
-        e = secsToElapsedTimeString(self.workspace.getElapsedSecs())
+        e = self.workspace.getElapsedTimeString()
         if e : detailsTable.createEntry("Elapsed Time : ", e)
         detailsTable.createEntry("Base Directory : ", self.workspace.getBaseDirectory())
         detailsTable.createEntry("Temporary Directory : ", self.workspace.tmpdir)

Modified: gump/trunk/python/gump/utils/timing.py
==============================================================================
--- gump/trunk/python/gump/utils/timing.py	(original)
+++ gump/trunk/python/gump/utils/timing.py	Wed Sep 22 08:50:26 2004
@@ -57,6 +57,11 @@
 DSTDIFF = DSTOFFSET - STDOFFSET
 
 class LocalTimezone(datetime.tzinfo):
+    """
+    
+    A timezone relying upon the local host's configuration
+    
+    """
 
     def utcoffset(self, dt):
         if self._isdst(dt):
@@ -217,7 +222,10 @@
     
     return diffString
     
-class TimeStamp:       
+class TimeStamp: 
+    """
+    A simple timestamp (a wrapper around datetime.datetime)
+    """
     def __init__(self,name,stamp=None):
         self.name=name               
         if not stamp:
@@ -251,6 +259,9 @@
         return (self.timestamp < other.timestamp)
         
 class TimeStampRange:       
+    """
+    A set of two TimeStamps (start -> end)
+    """
     def __init__(self,name,start=None,end=None,external=False):
         
         self.name=name
@@ -268,7 +279,7 @@
         return self.getElapsedSecs() > 0
         
     def __str__(self):
-        return 'TimeStamp: '+self.name+' : '+ \
+        return 'TimeStamp: ' + self.name + ' : ' + \
                 secsToElapsedTimeString(self.getElapsedSecs()) 
                 
     def setEnd(self,end=None):             
@@ -306,27 +317,37 @@
         return self.external
 
 class TimeStampSet(list):
-    """   
+    """ 
+      
         A named collection of timestamps                
+        
     """
     def __init__(self,name,start=None):
         list.__init__(self)
         
         self.name=name        
-        if not start:
-            start=TimeStamp('Start of ' + name)
+        if not start:start=TimeStamp('Start of ' + name)
         self.startTimeStamp=start        
         self.endTimeStamp=start
         
     def registerStamp(self,stamp):   
-        return self.store(stamp)
+        """
+        Register a TimeStamp
+        """
+        return self._store(stamp)
         
     def registerRange(self,range): 
+        """
+        Register a TimeStampRange
+        """
+        
+        
+        #:TODO: BUG!!!!
         return self._store(range)
             
     def stamp(self,sname):
         """
-        	Calculate and provide a stamp
+        	Calculate and provide a named stamp
         """
         # Stamp (end calculated)...       
         stamp=TimeStamp(sname)  
@@ -345,8 +366,18 @@
         # :TODO: don't assume stored in time order
         self.endTimeStamp=stamp  
         
-        
     def getElapsedSecs(self):
+        return deltaToSecs(self.getElapsedTime())
+        
+    def getElapsedTimeString(self):
+        return secsToElapsedTimeString(self.getElapsedSecs())         
+        
+    def getElapsedTime(self):
+        """
+        Get elapsed time as a delta between 'start' and 'end'.
+        
+        datetime.timedelta
+        """
         return self.endTimeStamp.getTimestamp() - self.startTimeStamp.getTimestamp()
         
     def getTotalTimes(self):
@@ -366,19 +397,41 @@
         elapsed=self.getElapsedSecs()
         
         return (elapsed, accounted, external)
-       
-    # :TODO: Move these to run, like much dynamic stuff on W/S
-
-    def setStart(self,comment='Start'):                                
+    
+    def hasStart(self):
+        if self.startTimeStamp: return True
+        return False
+        
+    def hasEnd(self):
+        if self.endTimeStamp: return True
+        return False
+        
+    def setStart(self,comment='Start'):
+        """
+        Set the start (first) time
+        """                            
         self.stamp(comment)
         
-    def setEnd(self,comment='End'):                             
+    def setEnd(self,comment='End'):    
+        """
+        Set the last (first) time
+        """                         
         self.stamp(comment)                                   
         
     def getStart(self):
+        """
+        Get the first time
+        
+        gump.times.TimeStamp
+        """        
         return self.startTimeStamp
         
     def getEnd(self):
+        """
+        Get the last time
+        
+        gump.times.TimeStamp
+        """            
         return self.endTimeStamp
         
     def importTimes(self,otherSet):
@@ -397,51 +450,56 @@
             output.write(spacing)
             output.write(str(entry))
             output.write('\n')
-            
-class TimeStampSetSet(list):   
-    def __init__(self):
-        list.__init__(self)
-        
-    def getTotalTimes(self):
-        
-        elapsed=0
-        accounted=0
-        external=0
-        
-        # Count external/ranges
-        for entry in self:
-            (e,a,ex)=entry.getTotalTimes()
-            
-            elapsed += e
-            accounted += a
-            external += ex
-            
-        return (elapsed, accounted, external)
+
+# Not sure we need this            
+#class TimeStampSetSet(list):   
+#    """
+#    	A set of sets
+#   	"""
+#    def __init__(self):
+#        list.__init__(self)
+#        
+#    def getTotalTimes(self):
+#        
+#        elapsed=0
+#        accounted=0
+#        external=0
+#        
+#        # Count external/ranges
+#        for entry in self:
+#            (e,a,ex)=entry.getTotalTimes()
+#            
+#            elapsed += e
+#            accounted += a
+#            external += ex
+#            
+#        return (elapsed, accounted, external)
         
 class Timeable:
-    def __init__(self,name):        
+    """
+    
+    	An entity that can hold times.
+    	
+    """
+    def __init__(self,name):     
+        # Need to name the set after 'owner'.
         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='Start'):
-        self.times.setStart(comment)
+        # Proxy some methods...
+        setattr(self,'setStart', self.times.setStart)
+        setattr(self,'hasStart', self.times.hasStart)
+        setattr(self,'getStart', self.times.getStart)
+        setattr(self,'setEnd', self.times.setEnd)
+        setattr(self,'hasEnd', self.times.hasEnd)
+        setattr(self,'getEnd', self.times.getEnd)
         
-    def getStart(self):
-        return self.times.getStart()
-    
-    def hasEnd(self):
-        return self.times.hasEnd()
+        setattr(self,'getElapsedTimeString', self.times.getElapsedTimeString)
         
-    def setEnd(self,comment='End'):
-        self.times.setEnd(comment)
+    def getTimes(self):
+        """
+        Hands on access to the times        
+        """
+        return self.times
         
-    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	Wed Sep 22 08:50:26 2004
@@ -89,27 +89,18 @@
     def __init__(self,name,type,state,start,end,message=''):
         WorkItem.__init__(self,name,type,state,message)
         self.timerange=TimeStampRange(name,
-                                TimeStamp(name,start),
-                                TimeStamp(name,end),
+                                TimeStamp('Start of ' + name, start),
+                                TimeStamp('End of ' + name,   end),
                                 True)
-    
-    def hasStart(self):
-        return self.timerange.hasStart()
-        
-    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():
-            return self.timerange.getElapsedSecs()
-        return 0
+                                
+        # Proxy some methods...
+        setattr(self,'hasStart',self.timerange.hasStart)
+        setattr(self,'getStart',self.timerange.getStart)
+        setattr(self,'hasEnd',self.timerange.hasEnd)
+        setattr(self,'getEnd',self.timerange.getEnd)
         
+        setattr(self,'getElapsedSecs',self.timerange.getElapsedSecs)
+      
     def getRange(self):
         return self.timerange
          
@@ -183,12 +174,12 @@
         self.nameIndex={}
         
         # Timings
-        self.timing=TimeStampSet('Named Work')  
+        self.times=TimeStampSet('Named Work')  
             	
     def __del__(self):
         Ownable.__del__(self)
         self.nameIndex=None
-        self.timing=None
+        self.times=None
         
     def shutdown(self):
         self.nameIndex=None
@@ -215,7 +206,7 @@
         
         # Register this time...
         if isinstance(item,TimedWorkItem):
-            self.timing.registerRange(item.getRange())
+            self.times.registerRange(item.getRange())
         
         # Let this item know its owner
         item.setOwner(self.getOwner())
@@ -254,6 +245,9 @@
             if isinstance(item,TimedWorkItem): 
                 elapsedSecs += item.getElapsedSecs()
         return elapsedSecs
+        
+    def getElapsedTimeString(self):
+        return secsToElapsedTimeString(self.getElapsedSecs())
                 
     def clone(self):
         cloned=WorkList()
@@ -261,13 +255,22 @@
             cloned.add(item.clone())
         return cloned
         
-    def getTiming(self):
-        return timing
+    def getTimes(self):
+        return times
         
 class Workable(Stateful):       
     def __init__(self):
         Stateful.__init__(self)
         self.worklist=WorkList(self)
+        
+        setattr(self, 'hasStart', self.worklist.hasStart)
+        setattr(self, 'getStart', self.worklist.getStart)
+        setattr(self, 'hasEnd', self.worklist.hasEnd)
+        setattr(self, 'getEnd', self.worklist.getEnd)
+        setattr(self, 'hasTimes', self.worklist.hasTimes)
+        setattr(self, 'getTimes', self.worklist.getTimes)
+        setattr(self, 'getElapsedSecs', self.worklist.getElapsedSecs)
+        setattr(self, 'getElapsedTimeString', self.worklist.getElapsedTimeString)
                 
     def __del__(self):
         # None @ present ... Stateful.__del__(self)
@@ -279,23 +282,6 @@
     def performedWork(self,item):
     	self.worklist.add(item)           	
     
-    def hasStart(self):
-        return self.worklist.hasStart()
-          
-    def getStart(self):
-        return self.worklist.getStart()   
-          
-    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()
         
     def shutdownWork(self):
         self.worklist.shutdown()

Mime
View raw message