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/document forrest.py
Date Wed, 28 Jan 2004 00:13:39 GMT
ajack       2004/01/27 16:13:39

  Modified:    python/gump engine.py
               python/gump/utils __init__.py launcher.py work.py
               python/gump/test pyunit.py
               python/gump/output xref.py nag.py
               python/gump/model rawmodel.py state.py
               python/gump/document forrest.py
  Added:       python/gump/test nagging.py
  Log:
  1) Added nagging 'unit' test.
  2) Brought nagging back to life (ready to start sending...)
  3) Fixed 'outputs (jars)' -> projects (the 'None' w/ all)
  4) Added 'Outputs' (jars) to project details page [for reference]
  5) Allow nagging for modules (e.f. CVS/SVN failed...) 
  Currently only nag on project(today)  in Traditional Gump, I beleive...
  
  
  6) Disabled sending mails, to do some more practice first...
  
  Revision  Changes    Path
  1.48      +3 -1      jakarta-gump/python/gump/engine.py
  
  Index: engine.py
  ===================================================================
  RCS file: /home/cvs/jakarta-gump/python/gump/engine.py,v
  retrieving revision 1.47
  retrieving revision 1.48
  diff -u -r1.47 -r1.48
  --- engine.py	12 Jan 2004 18:01:36 -0000	1.47
  +++ engine.py	28 Jan 2004 00:13:39 -0000	1.48
  @@ -137,8 +137,10 @@
           #
           #	Nag and provide RSS
           #
  -        if run.getGumpSet().isFull():
  +        if run.getGumpSet().isFull() and run.getWorkspace().isNag():
     
  +            log.info('Nag about failures... ')
  +            
               #
               # Nag about failures
               #
  
  
  
  1.17      +4 -4      jakarta-gump/python/gump/utils/__init__.py
  
  Index: __init__.py
  ===================================================================
  RCS file: /home/cvs/jakarta-gump/python/gump/utils/__init__.py,v
  retrieving revision 1.16
  retrieving revision 1.17
  diff -u -r1.16 -r1.17
  --- __init__.py	21 Jan 2004 18:52:30 -0000	1.16
  +++ __init__.py	28 Jan 2004 00:13:39 -0000	1.17
  @@ -376,7 +376,7 @@
     print "secsToElapsedTimeTriple(1340) : " + str(secsToElapsedTimeTriple(1340))
     print "secsToElapsedString(1340) : " + secsToElapsedString(1340)
     print "secsToTime(1340) : " + secsToTime(1340)
  -  print "elapsedTimeToString(secsToElapsedTime(1340)) : " + elapsedTimeTripleToString(secsToElapsedTimeTriple(1340))
  +  print "elapsedTimeTripleToString(secsToElapsedTimeTriple(1340)) : " + elapsedTimeTripleToString(secsToElapsedTimeTriple(1340))
     
     print "str = " + getStringFromUnicode("Ceki Gülcü")
     
  
  
  
  1.9       +1 -1      jakarta-gump/python/gump/utils/launcher.py
  
  Index: launcher.py
  ===================================================================
  RCS file: /home/cvs/jakarta-gump/python/gump/utils/launcher.py,v
  retrieving revision 1.8
  retrieving revision 1.9
  diff -u -r1.8 -r1.9
  --- launcher.py	9 Jan 2004 19:57:19 -0000	1.8
  +++ launcher.py	28 Jan 2004 00:13:39 -0000	1.9
  @@ -288,7 +288,7 @@
           if self.output:
             overview += indent+"Output: " + self.output
           if self.hasTimes():
  -          overview += indent+"Elapsed: " + str(self.getElapsedTime())
  +          overview += indent+"Elapsed: " + self.getElapsedTimeString()
           if self.signal:
             overview += indent+"Termination Signal: " + str(self.signal)
           if self.exit_code:
  
  
  
  1.7       +6 -3      jakarta-gump/python/gump/utils/work.py
  
  Index: work.py
  ===================================================================
  RCS file: /home/cvs/jakarta-gump/python/gump/utils/work.py,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- work.py	9 Jan 2004 19:57:19 -0000	1.6
  +++ work.py	28 Jan 2004 00:13:39 -0000	1.7
  @@ -147,12 +147,15 @@
               return int(round(self.endSecs-self.startSecs,0))
           return 0
           
  -    def getElapsedTime(self):   
  -        return secsToElapsedTime(self.getElapsedSecs())
  +    def getElapsedTimeString(self):   
  +        return secsToElapsedTimeString(self.getElapsedSecs())
  +        
  +    def getElapsedTimeTriple(self):   
  +        return secsToElapsedTimeTriple(self.getElapsedSecs())
            
       def overview(self):
           overview=WorkItem.overview(self)
  -        (hours,mins,secs)=self.getElapsedTime()
  +        (hours,mins,secs)=self.getElapsedTimeTriple()
           overview+='Elapsed: '
           overview+=str(hours) + ' hours, ' 
           overview+=str(mins) + ' minutes, ' 
  
  
  
  1.18      +8 -5      jakarta-gump/python/gump/test/pyunit.py
  
  Index: pyunit.py
  ===================================================================
  RCS file: /home/cvs/jakarta-gump/python/gump/test/pyunit.py,v
  retrieving revision 1.17
  retrieving revision 1.18
  diff -u -r1.17 -r1.18
  --- pyunit.py	9 Jan 2004 23:41:41 -0000	1.17
  +++ pyunit.py	28 Jan 2004 00:13:39 -0000	1.18
  @@ -347,8 +347,11 @@
       from gump.test.tools import ToolsTestSuite  
       runner.addSuite(ToolsTestSuite())
       
  -    #from gump.test.integrator import IntegratorTestSuite  
  -    #runner.addSuite(IntegratorTestSuite())
  +    from gump.test.tools import ToolsTestSuite  
  +    runner.addSuite(ToolsTestSuite())
  +    
  +    from gump.test.nagging import NaggingTestSuite  
  +    runner.addSuite(NaggingTestSuite())
       
       # Any args are pattern matches
       patterns=list(sys.argv)
  
  
  
  1.1                  jakarta-gump/python/gump/test/nagging.py
  
  Index: nagging.py
  ===================================================================
  #!/usr/bin/env python
  # $Header:  1.7 2003/05/10 18:20:36 nicolaken Exp $
  # $Revision: 1.7 $
  # $Date: 2003/05/10 18:20:36 $
  #
  # ====================================================================
  #
  # The Apache Software License, Version 1.1
  #
  # Copyright (c) 2003 The Apache Software Foundation.  All rights
  # reserved.
  #
  # Redistribution and use in source and binary forms, with or without
  # modification, are permitted provided that the following conditions
  # are met:
  #
  # 1. Redistributions of source code must retain the above copyright
  #    notice, this list of conditions and the following disclaimer.
  #
  # 2. Redistributions in binary form must reproduce the above copyright
  #    notice, this list of conditions and the following disclaimer in
  #    the documentation and/or other materials provided with the
  #    distribution.
  #
  # 3. The end-user documentation included with the redistribution, if
  #    any, must include the following acknowlegement:
  #       "This product includes software developed by the
  #        Apache Software Foundation (http://www.apache.org/)."
  #    Alternately, this acknowlegement may appear in the software itself,
  #    if and wherever such third-party acknowlegements normally appear.
  #
  # 4. The names "The Jakarta Project", "Alexandria", and "Apache Software
  #    Foundation" must not be used to endorse or promote products derived
  #    from this software without prior written permission. For written
  #    permission, please contact apache@apache.org.
  #
  # 5. Products derived from this software may not be called "Apache"
  #    nor may "Apache" appear in their names without prior written
  #    permission of the Apache Group.
  #
  # THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
  # WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
  # OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  # DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
  # ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
  # USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  # ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
  # OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
  # OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  # SUCH DAMAGE.
  # ====================================================================
  #
  # This software consists of voluntary contributions made by many
  # individuals on behalf of the Apache Software Foundation.  For more
  # information on the Apache Software Foundation, please see
  # <http://www.apache.org/>.
  
  """
      Model Testing
  """
  
  import os
  import logging
  import types, StringIO
  
  from gump import log
  import gump.config
  from gump.gumprun import GumpRun
  from gump.test import getWorkedTestWorkspace
  from gump.test.pyunit import UnitTestSuite
  from gump.output.nag import nag,getContent
  
  class NaggingTestSuite(UnitTestSuite):
      def __init__(self):
          UnitTestSuite.__init__(self)
          
      def suiteSetUp(self):
          #
          # Load a decent Workspace
          #
          self.workspace=getWorkedTestWorkspace()          
          self.assertNotNone('Needed a workspace', self.workspace)
          self.run=GumpRun(self.workspace)
          
      def testNagContents(self):
      
          # For all modules...
          for module in self.workspace.getModules():                    
              print 'Get Content For Module : ' + module.getName()
              print getContent(self.run,self.workspace,module,'Testing Module...')
              for project in module.getProjects():
                  print 'Get Content For Project : ' + project.getName()
                  print getContent(self.run,self.workspace,project,'Testing Project...')
                  
      def testNag(self):
          nag(self.run)
          
  
  
  1.7       +17 -23    jakarta-gump/python/gump/output/xref.py
  
  Index: xref.py
  ===================================================================
  RCS file: /home/cvs/jakarta-gump/python/gump/output/xref.py,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- xref.py	23 Jan 2004 23:32:27 -0000	1.6
  +++ xref.py	28 Jan 2004 00:13:39 -0000	1.7
  @@ -153,34 +153,28 @@
       
       
       def mapOutputs(self):
  -        for module in self.workspace.getModules():
  -            
  -            for project in module.getProjects():
  -                
  +        for module in self.workspace.getModules():            
  +            for project in module.getProjects():                
                   if project.hasJars():
  -
  -                    for jar in project.getJars():      
  -                        jarName=jar.getName()                 
  +                    for jar in project.getJars():  
  +                        jarName=os.path.basename(jar.getName())            
                           if not self.outputToProject.has_key(jarName):
                               self.outputToProject[jarName]=[]
                       
  -                    if not project in self.outputToProject[jarName]:
  -                        self.outputToProject[jarName].append(project)
  -    
  +                        if not project in self.outputToProject[jarName]:
  +                            self.outputToProject[jarName].append(project)
       
       def mapDescriptorLocations(self):
  -        for module in self.workspace.getModules():
  -            
  -            for project in module.getProjects():
  -                
  -                locn=str(project.xml.href)
  +        for module in self.workspace.getModules():            
  +            for project in module.getProjects():                
  +                metadataLocation=str(project.xml.href)
                       
  -                if locn:          
  -                    if not self.outputToProject.has_key(locn):
  -                        self.outputToProject[locn]=[]
  +                if metadataLocation:          
  +                    if not self.descriptorLocationToProject.has_key(metadataLocation):
  +                        self.descriptorLocationToProject[metadataLocation]=[]
                       
  -                    if not project in self.outputToProject[locn]:
  -                        self.outputToProject[locn].append(project)
  +                    if not project in self.descriptorLocationToProject[metadataLocation]:
  +                        self.descriptorLocationToProject[metadataLocation].append(project)
       
       def getRepositoryToModuleMap(self):
           return self.repositoryToModule
  
  
  
  1.6       +95 -37    jakarta-gump/python/gump/output/nag.py
  
  Index: nag.py
  ===================================================================
  RCS file: /home/cvs/jakarta-gump/python/gump/output/nag.py,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- nag.py	9 Jan 2004 19:57:18 -0000	1.5
  +++ nag.py	28 Jan 2004 00:13:39 -0000	1.6
  @@ -72,7 +72,9 @@
   
   from gump import log
   from gump.config import *
  -from gump.model import *
  +from gump.model.project import *
  +from gump.model.module import *
  +from gump.model.state import *
   from gump.net.mailer import *
   from gump.utils import *
   
  @@ -81,6 +83,9 @@
       workspace=run.getWorkspace()
       gumpSet=run.getGumpSet()
       
  +    #
  +    # Belt and braces...
  +    #
       if not workspace.isNag():
           return
   
  @@ -88,31 +93,77 @@
       # Nag about the workspace (if it needs it)
       #
       if workspace.isFailed():
  -        nagWorkspace(workspace)
  +        nagWorkspace(run,workspace)
       
       # For all modules...
  -    for modules in workspace.getModules():        
  +    for module in workspace.getModules():        
               if not gumpSet.inModules(module): continue
  -            
  -            for project in module.getProjects():
  -                if project.isFailed() :
  -                    if not gumpSet.inSequence(project): continue    
  +
  +            if module.isFailed():
  +                try:
  +                    log.info('Nag for module: ' + module.getName())                   
    
                       
  -                    # :TODO: Something doesn't work w/ this.
  -                    # if projectFilterList and not pctxt.project in projectFilterList:
continue
  -                    try:
  -                        nagProject(project,workspace)
  -                    except Exception, details:
  -                        log.error("Failed to send nag e-mails for project " + project.getName()\
  -                                            + " : " + str(details))
  +                    nagModule(run,workspace,module)   
  +                                         
  +                except Exception, details:
  +                    log.error("Failed to send nag e-mails for module " + module.getName()\
  +                                + " : " + str(details), exc_info=1)
  +            else:
  +                for project in module.getProjects():
  +                    if project.isFailed() :
  +                        if not gumpSet.inSequence(project): continue                  
     
  +                        
  +                        try:
  +                        
  +                            log.info('Nag for project: ' + project.getName())         
              
  +                            nagProject(run,workspace,project)                        
  +                        except Exception, details:
  +                            log.error("Failed to send nag e-mails for project " + project.getName()\
  +                                            + " : " + str(details), exc_info=1)
                   
                   
  -def nagWorkspace(workspace):
  +def nagWorkspace(run,workspace):
       """ Nag for the workspace """
       content=getContent(workspace, "There is a workspace problem... \n")
       sendEmail(workspace,workspace.mailinglist,workspace.email,workspace.prefix+': Gump
Workspace Problem ',content)
       
  -def nagProject(workspace,project):
  +def nagModule(run,workspace,module):
  +    """ Nag to a specific module's <nag entry """
  +    content=''
  +    
  +    #
  +    # Form the content...
  +    #
  +    content+=getContent(run,workspace,module,"Module: " + module.getName() + "\n")
  +                
  +    #
  +    # Form the sujhect
  +    #
  +    subject=workspace.prefix+': '+module.getName()+' '+lower(stateName(module.getState()))
  +    
  +    nags=0
  +    for nagEntry in module.xml.nag:
  +        try:
  +            #
  +            # Form and send the e-mail...
  +            #
  +            toaddr=getattr(nagEntry,'to',workspace.mailinglist)
  +            fromaddr=getattr(nagEntry,'from',workspace.mailinglist)
  +            
  +            sendEmail(workspace,toaddr,fromaddr,subject,content)
  +            
  +            nags+=1
  +        except Exception, details:
  +            log.error("Failed to send nag e-mail for module " + module.name \
  +                    + " : " + str(details))
  +            log.error(content, exc_info=1)
  +            
  +    # Belt and braces (nag to us if not nag to them)
  +    if not nags:
  +        sendEmail(workspace,workspace.mailinglist,workspace.mailinglist,subject,content)
  +    
  +    
  +def nagProject(run,workspace,project):
       """ Nag to a specific project's <nag entry """
       content=''
       
  @@ -123,18 +174,18 @@
       #
       displayedModule=0
       displayedProject=0
  -    if not STATE_SUCCESS == module.getState():
  +    if not module.isSuccess():
           displayedModule=1
  -        content+=getContent(workspace,module,"Module: " + module.getName() + "\n")
  +        content+=getContent(run,workspace,module,"Module: " + module.getName() + "\n")
           
  -    if not STATE_SUCCESS == project.getState():
  +    if not project.isSuccess():
           displayedProject=1    
  -        content+=getContent(workspace,project,"Project: " + project.getName() + "\n"  
 )
  +        content+=getContent(run,workspace,project,"Project: " + project.getName() + "\n"
   )
           
       # No clue why this would happen, but fallback safe...
       if not displayedModule and not displayedProject:
  -        content+=getContent(workspace,module,"Module: " + module.getName() + "\n") 
  -        content+=getContent(workspace,project,"Project: " + project.getName() + "\n")
  +        content+=getContent(run,workspace,module,"Module: " + module.getName() + "\n")

  +        content+=getContent(run,workspace,project,"Project: " + project.getName() + "\n")
                   
       #
       # Form the sujhect
  @@ -142,7 +193,7 @@
       subject=workspace.prefix+': '+module.getName()+'/'+project.getName()+' '+lower(stateName(project.getState()))
       
       nags=0
  -    for nagEntry in project.nag:
  +    for nagEntry in project.xml.nag:
           try:
               #
               # Form and send the e-mail...
  @@ -156,7 +207,7 @@
           except Exception, details:
               log.error("Failed to send nag e-mail for project " + project.name \
                       + " : " + str(details))
  -            log.error(content)
  +            log.error(content, exc_info=1)
               
       # Belt and braces (nag to us if not nag to them)
       if not nags:
  @@ -174,11 +225,18 @@
       email=EmailMessage( toaddrs, \
                           fromaddr, \
                           subject, \
  -                        content)                            
  +                        content)       
  +                        
  +    print 'To:' + `toaddrs`
  +    print 'From:' + `toaddrs`
  +    print 'Subject:' + `toaddrs`
  +    print 'Server:' + `workspace.mailserver`
  +    print 'e-mail:' + `email`
  +    
       # Fire ...
  -    mail(toaddrs,fromaddr,email,workspace.mailserver) 
  +    #mail(toaddrs,fromaddr,email,workspace.mailserver) 
               
  -def getContent(workspace,object,message=''):
  +def getContent(run,workspace,object,message=''):
       content=''
       
       # Optional message
  @@ -190,30 +248,30 @@
       #
       content += "State: " + object.getStateDescription() + "\n"
       
  -    if not object.reason == REASON_UNSET:
  +    if not object.hasReason():
           content +=  "Reason: " + object.getReasonDescription() + "\n"
                                    
       #
       # Link them back here...
       #
  -    url=workspace.documenter.getObjectLink(object)
  +    url=run.getOptions().getResolver().getUrl(object)
       content += "URL: " + url + "\n"
       
       #
       # Add an info/error/etc...
       #
  -    if object.annotations:
  -        content += "\n\nAnnotations:\n"
  -        for note in object.annotations:      
  -            content += (' - %s - %s\n' % (levelName(note.level), note.text))
  +    #if object.annotations:
  +    #    content += "\n\nAnnotations:\n"
  +    #    for note in object.annotations:      
  +    #        content += (' - %s - %s\n' % (levelName(note.level), note.text))
       
       #
       # Work
       #
  -    if object.worklist:
  -        content+="\n\nWork Items:\n"
  -        for workitem in object.worklist:
  -            content+=workitem.overview()+"\n"            
  +    #if object.worklist:
  +    #    content+="\n\nWork Items:\n"
  +    #    for workitem in object.worklist:
  +    #        content+=workitem.overview()+"\n"            
       
       return content
       
  
  
  
  1.11      +1 -0      jakarta-gump/python/gump/model/rawmodel.py
  
  Index: rawmodel.py
  ===================================================================
  RCS file: /home/cvs/jakarta-gump/python/gump/model/rawmodel.py,v
  retrieving revision 1.10
  retrieving revision 1.11
  diff -u -r1.10 -r1.11
  --- rawmodel.py	9 Jan 2004 19:57:18 -0000	1.10
  +++ rawmodel.py	28 Jan 2004 00:13:39 -0000	1.11
  @@ -138,6 +138,7 @@
       self.url=Single(GumpXMLModelObject)
       self.description=Single(GumpXMLModelObject)
       self.redistributable=Single(GumpXMLModelObject)
  +    self.nag=Multiple(XMLNag)
       self.project=Multiple(XMLProject)
   
   # represents a <repository/> element
  
  
  
  1.10      +4 -0      jakarta-gump/python/gump/model/state.py
  
  Index: state.py
  ===================================================================
  RCS file: /home/cvs/jakarta-gump/python/gump/model/state.py,v
  retrieving revision 1.9
  retrieving revision 1.10
  diff -u -r1.9 -r1.10
  --- state.py	9 Jan 2004 19:57:18 -0000	1.9
  +++ state.py	28 Jan 2004 00:13:39 -0000	1.10
  @@ -218,6 +218,10 @@
       def getStateDescription(self):
           return self.statePair.getStateDescription()
           
  +    def hasReason(self):
  +        if self.statePair.isReasonUnset(): return 0
  +        return 1
  +        
       def getReason(self):
           return self.statePair.reason
           
  
  
  
  1.58      +31 -4     jakarta-gump/python/gump/document/forrest.py
  
  Index: forrest.py
  ===================================================================
  RCS file: /home/cvs/jakarta-gump/python/gump/document/forrest.py,v
  retrieving revision 1.57
  retrieving revision 1.58
  diff -u -r1.57 -r1.58
  --- forrest.py	23 Jan 2004 23:32:27 -0000	1.57
  +++ forrest.py	28 Jan 2004 00:13:39 -0000	1.58
  @@ -444,6 +444,8 @@
               self.resolver.getFile(workspace,'project_todos'))        
           self.documentSummary(document, workspace.getProjectSummary())
           
  +        totalAffected=0
  +        
           projectsSection=document.createSection('Projects with issues...')
           projectsTable=projectsSection.createTable(['Name','Affected',	\
                       'Duration\nin state','Project State','Elapsed'])
  @@ -462,6 +464,8 @@
               #
               affected=project.determineAffected()
               
  +            totalAffected += affected
  +            
               # How long been like this
               seq=stats=project.getStats().sequenceInState
                       
  @@ -476,7 +480,12 @@
               self.insertStateIcon(project,workspace,projectRow.createData())
               projectRow.createData(secsToElapsedString(project.getElapsedSecs())) 
                   
  -        if not pcount: projectsTable.createLine('None')    
  +        if not pcount: 
  +            projectsTable.createLine('None')    
  +        else:
  +            projectsSection.createParagraph(
  +                    'Total Affected Projects: ' + str(totalAffected))
  +                    
           document.serialize()
              
           #
  @@ -982,6 +991,24 @@
       #                % (getModuleProjectRelativeUrl(modulename,project.name)) )       
             
              
           miscSection=document.createSection('Miscellaneous')
  +        
  +        #
  +        #	Outputs (e.g. Jars)
  +        #
  +        if project.hasJars():
  +            outputSection = miscSection.createSection('Outputs')
  +            outputTable = outputSection.createTable(['Name','Id'])
  +            
  +            for jar in project.getJars():
  +                outputRow=outputTable.createRow()
  +                
  +                # The name (path) of the jar
  +                outputRow.createData(jar.getName())
  +                
  +                # The jar id
  +                id=jar.getId() or 'N/A'
  +                outputRow.createData(id)                                
  +        
               
           if project.hasBuildCommand():
               
  
  
  

Mime
View raw message