gump-general mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From aj...@apache.org
Subject cvs commit: jakarta-gump/python/gump integrate.py context.py utils.py document.py
Date Thu, 25 Sep 2003 19:33:49 GMT
ajack       2003/09/25 12:33:49

  Modified:    python/gump integrate.py context.py utils.py document.py
  Log:
  1) Re-used time formatting
  2) Fixed icon
  3) Start of work on "sumarizing results"
  
  Revision  Changes    Path
  1.2       +2 -2      jakarta-gump/python/gump/integrate.py
  
  Index: integrate.py
  ===================================================================
  RCS file: /home/cvs/jakarta-gump/python/gump/integrate.py,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- integrate.py	29 Aug 2003 00:20:22 -0000	1.1
  +++ integrate.py	25 Sep 2003 19:33:49 -0000	1.2
  @@ -91,8 +91,8 @@
           # Provide a news feed
           rss(workspace,context)
   
  -    #display(context)
  -    result = context.status
  +    # Return an exit code based off success
  +    result = stateOk(context.status) ? 0 : 1
   
   # static void main()
   if __name__=='__main__':
  
  
  
  1.10      +36 -3     jakarta-gump/python/gump/context.py
  
  Index: context.py
  ===================================================================
  RCS file: /home/cvs/jakarta-gump/python/gump/context.py,v
  retrieving revision 1.9
  retrieving revision 1.10
  diff -u -r1.9 -r1.10
  --- context.py	25 Sep 2003 17:04:52 -0000	1.9
  +++ context.py	25 Sep 2003 19:33:49 -0000	1.10
  @@ -125,8 +125,7 @@
                       LEVEL_INFO : "Info",
                       LEVEL_WARNING : "Warning",
                       LEVEL_ERROR : "Error",
  -                    LEVEL_FATAL : "Fatal" }    
  -           
  +                    LEVEL_FATAL : "Fatal" }               
   
   def levelName(level):
       return levelDescriptions.get(level,'Unknown Level:' + str(level))
  @@ -296,6 +295,15 @@
           cmp = self.state < other.state
           if not cmp: cmp = self.reason < other.reason
           return cmp
  +
  +class Summary:
  +    """ Contains an overview """
  +    def __init__(self,successes,failures,prereqs,other,statepairs):
  +        self.successes=successes
  +        self.failures=failures
  +        self.prereqs=prereqs
  +        self.other=other
  +        self.statepair=statepairs
           
   class Context:
       """Context for a single entity"""
  @@ -351,13 +359,38 @@
       def aggregateStates(self, states=None):
           if not states: states=[]
           pair=self.getStatePair()
  -        # Add self, if not already there
  +        # Add state, if not already there
           if not stateUnset(pair.state) and not pair in states: \
               states.append(pair)
           # Subbordinates
           for ctxt in self:
               ctxt.aggregateStates(states)
           return states;
  +        
  +    def getSummary(self,summary=None):            
  +        if not summary: 
  +            summary=Summary(0,0,0,0,[])
  +            
  +        # Stand up and be counted
  +        if not stateUnit(self.state):
  +            if stateOk(self.state):
  +                summary.successes+=1
  +            elif STATUS_PREREQ_FAILURE == self.state:
  +                summary.prereqs+=1
  +            elif STATUS_FAILED == self.state:
  +                summary.failures+=1
  +            else:
  +                summary.other+=1
  +                
  +        # Add state, if not already there
  +        if not stateUnset(pair.state) and not pair in summary.statepairs: \
  +            summary.statepairs.append(pair)
  +       
  +        # Subordinates
  +        for ctxt in self:
  +            ctxt.getSummary(summary)
  +            
  +        return summary;
               
       def propagateErrorState(self,state,reason=REASON_UNSET,cause=None):
           #
  
  
  
  1.3       +34 -1     jakarta-gump/python/gump/utils.py
  
  Index: utils.py
  ===================================================================
  RCS file: /home/cvs/jakarta-gump/python/gump/utils.py,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- utils.py	23 Sep 2003 23:16:20 -0000	1.2
  +++ utils.py	25 Sep 2003 19:33:49 -0000	1.3
  @@ -65,6 +65,9 @@
   import logging
   import types, StringIO
   
  +from gump  import log
  +from gump.conf import default
  +
   ###############################################################################
   # Base classes for the Displayable Objects
   ###############################################################################
  @@ -164,6 +167,32 @@
       if not f: f = sys.stdout
       f.write( '%s\n' % (indent + ' ----------------------------------------------------
Gumpy'))
   
  +def secsToElapsedTime(secs):   
  +    # Extract Hours
  +    if secs > 3600:
  +        hours	=	int(secs / 3600)
  +        secs	%=	3600
  +    else:
  +        hours	=	0
  +          
  +    # Extract Minutes  
  +    if secs > 60:
  +        mins	=	int(secs / 60)
  +        secs	%=	60
  +    else:
  +        mins 	= 	0
  +            
  +    # Seconds
  +    secs 	=	int(round(secs,0))
  +        
  +    return (hours, mins, secs)
  +    
  +def secsToString(secs):
  +    return ('%02d:%02d:%02d' % secsToElapsedTime(secs))           
  +    
  +def elapsedTimeToString(elapsed):
  +    return ('%02d:%02d:%02d' % elapsed)           
  +    
   if __name__=='__main__':
   
     # init logging
  @@ -172,5 +201,9 @@
     #set verbosity to show all messages of severity >= default.logLevel
     log.setLevel(default.logLevel)
     
  -  dump(log)
  +  #dump(log)
  +
  +  print "secsToElapsedTime(1340) : " + str(secsToElapsedTime(1340))
  +  print "secsToString(1340) : " + secsToString(1340)
  +  print "elapsedTimeToString(secsToElapsedTime(1340)) : " + elapsedTimeToString(secsToElapsedTime(1340))
     
  
  
  
  1.40      +7 -10     jakarta-gump/python/gump/document.py
  
  Index: document.py
  ===================================================================
  RCS file: /home/cvs/jakarta-gump/python/gump/document.py,v
  retrieving revision 1.39
  retrieving revision 1.40
  diff -u -r1.39 -r1.40
  --- document.py	25 Sep 2003 18:17:22 -0000	1.39
  +++ document.py	25 Sep 2003 19:33:49 -0000	1.40
  @@ -285,11 +285,11 @@
           if not Module.list.has_key(mname): continue        
           if moduleFilterList and not mctxt.module in moduleFilterList: continue
           mcount+=1
  -        (mhours, mmins, msecs) 	= mctxt.elapsedTime();
  +
           x.write('     <tr><!-- %s -->\n' % (mname))        
           x.write('      <td><link href=\'%s\'>%s</link></td><td>%s</td>\n'
% \
             (getModuleRelativeUrl(mname),mname,getStateIcons(mctxt.aggregateStates()))) 
  
  -        x.write('      <td>%s:%s:%s</td>\n' % (str(mhours),str(mmins),str(msecs)))
   
  +        x.write('      <td>%s</td>\n' % elapsedTimeToString(mctxt.elapsedTime()))
   
           x.write('     </tr>\n\n')
       if not mcount: x.write('	<tr><td>None</td></tr>')
       endTableXDoc(x)
  @@ -401,12 +401,11 @@
           if projectFilterList and not pctxt.project in projectFilterList: continue  
           pname=pctxt.name    
           pcount+=1
  -           
  -        (phours, pmins, psecs) 	= pctxt.elapsedTime();
  +        
           x.write('     <tr><!-- %s -->' % (pname))        
           x.write('      <td><link href=\'%s\'>%s</link></td><td>%s</td><td>%s</td>'
% \
             (getProjectRelativeUrl(pname),pname,stateName(pctxt.status),reasonString(pctxt.reason)))
   
  -        x.write('      <td>%s:%s:%s</td>' % (str(phours),str(pmins),str(psecs)))
   
  +        x.write('      <td>%s</td>' % elapsedTimeToString(pctxt.elapsedTime()))
   
           x.write('     </tr>')
           
       if not pcount: x.write('	<tr><td>None</td></tr>')
  @@ -536,7 +535,7 @@
           x.write('     <tr><!-- %s -->' % (workTypeName(work.type)))       
           x.write('      <td><link href=\'%s\'>%s</link></td>' %
(getWorkRelativeUrl(work.type,work.command.name),work.command.name))    
           x.write('      <td>%s</td>' % (workTypeName(work.type))) 
  -        x.write('      <td>%s</td><td>%s secs.</td>' % (stateName(work.status),
str(work.secs)))    
  +        x.write('      <td>%s</td><td>%s</td>' % (stateName(work.status),
secsToString(work.secs)))    
           x.write('     </tr>')
       x.write('    </table>\n')
       endSectionXDoc(x)
  @@ -680,9 +679,7 @@
       startTableXDoc(x,'Modules By Elapsed')
       for mctxt in stats.modulesByElapsed:        
           if moduleFilterList and not mctxt.module in moduleFilterList: continue
  -        (hours,mins,secs)=mctxt.elapsedTime()
  -        timeFormat=str(hours)+":"+str(mins)+":"+str(secs)
  -        titledXDataInTableXDoc(x,getContextLink(mctxt), timeFormat)
  +        titledXDataInTableXDoc(x,getContextLink(mctxt), elapsedTimeToString(mctxt.elapsedTime()))
   
       endTableXDoc(x)
       
  @@ -982,7 +979,7 @@
       
       # Build the URL
       iconName=gumpSafeName(lower(replace(uniqueName,' ','_')))
  -    url = getUp(depth)+"resources/icons/"+iconName+".png";
  +    url = getUp(depth)+"icons/"+iconName+".png";
       
       # Build the <icon xdoc
       return '<icon src=\'' + url + '\' alt=\'' + description +'\'/>'
  
  
  

Mime
View raw message