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/output nag.py rss.py
Date Wed, 19 Nov 2003 15:42:16 GMT
ajack       2003/11/19 07:42:16

  Modified:    python/gump/model module.py rawmodel.py object.py state.py
                        ant.py project.py depend.py
               python/gump/test pyunit.py model_tests.py
               python/gump/document resolver.py
               python/gump/output nag.py rss.py
  Log:
  Some work on state propogation (prereq failures) and dependees
  
  Revision  Changes    Path
  1.5       +0 -1      jakarta-gump/python/gump/model/module.py
  
  Index: module.py
  ===================================================================
  RCS file: /home/cvs/jakarta-gump/python/gump/model/module.py,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- module.py	18 Nov 2003 19:02:25 -0000	1.4
  +++ module.py	19 Nov 2003 15:42:16 -0000	1.5
  @@ -63,7 +63,6 @@
   """
   
   from time import localtime, strftime, tzname
  -from string import lower, capitalize
   
   from gump.model.state import *
   from gump.model.project import *
  
  
  
  1.3       +0 -58     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.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- rawmodel.py	18 Nov 2003 17:29:17 -0000	1.2
  +++ rawmodel.py	19 Nov 2003 15:42:16 -0000	1.3
  @@ -191,64 +191,6 @@
       self.property=Multiple(XMLProperty)
       self.jvmarg=Multiple(GumpXMLModelObject)
   
  -  #
  -  # expand properties - in other words, do everything to complete the
  -  # entry that does NOT require referencing another project
  -  #
  -  def expand(self,project):
  -
  -    #
  -    # convert property elements which reference a project into dependencies
  -    #
  -    for property in self.property:
  -        
  -      # Check if the property comes from another project
  -      if not property.project: continue      
  -      # If that project is the one we have in hand
  -      if property.project==project.getName(): continue
  -      # If the property is not as simple as srcdir
  -      if property.reference=="srcdir": continue
  -      # If it isn't already a dependency
  -      if project.hasFullDependencyOn(property.project): continue
  -
  -      # Add a dependency (to bring property)
  -      depend=XMLDepend({'project':property.project})
  -      if not property.classpath: depend['noclasspath']=Single({})
  -      if property.runtime: depend['runtime']=property.runtime
  -    
  -      # :TODO: AJ added this, no idea if it is right/needed.
  -      if property.id: depend['ids']= property.id
  -      
  -      # Add depend to project...
  -      project.xml.depend.append(depend)
  -
  -    #
  -    # convert all depend elements into property elements, and
  -    # move the dependency onto the project
  -    #
  -    for depend in self.depend:
  -      # Generate the property
  -      property=XMLProperty(depend.__dict__)
  -      property['reference']='jarpath'
  -      
  -      # Name the property...
  -      if depend.property:
  -        property['name']=depend.property
  -      elif not hasattr(property,'name') or not property['name']:
  -        # :TODO: Reconsider later, but default to project name for now...
  -        property['name']=depend.project
  -        log.warn('Unnamed property for ' + project.name + ' in depend on: ' + depend.project
)
  -        
  -      # :TODO: AJ added this, no idea if it is right/needed.
  -      if depend.id: property['ids']= depend.id
  -      # Store it
  -      self.property.append(property)      
  -      # Move onto project
  -      project.depend.append(depend)
  -      
  -    self.depend=None
  -
  -
   # represents a <nag/> element
   class XMLNag(GumpXMLModelObject):
     def init(self):
  
  
  
  1.4       +14 -5     jakarta-gump/python/gump/model/object.py
  
  Index: object.py
  ===================================================================
  RCS file: /home/cvs/jakarta-gump/python/gump/model/object.py,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- object.py	18 Nov 2003 17:29:17 -0000	1.3
  +++ object.py	19 Nov 2003 15:42:16 -0000	1.4
  @@ -83,7 +83,7 @@
           self.cause=None	# Primary Cause
           self.causes=[]
               
  -    def changeState(self,state,reason=REASON_UNSET,cause=None):  
  +    def changeState(self,state,reason=REASON_UNSET,cause=None,message=None):  
           #
           # Do NOT over-write a pre-determined condition
           #            
  @@ -101,17 +101,26 @@
                   
                   # List of things that caused issues...
                   self.addCause(cause)
  -                
  +                                   
  +                #
  +                # Describe the problem
  +                #
  +                if not message:
  +                    message = lower(stateName(state))
  +                    if not REASON_UNSET == reason:
  +                        message += " with reason " + lower(reasonString(reason))      
     
  +                self.addError(capitalize(message))
  +        
                   # Send on the changes...
  -                self.propagateErrorStateChange(state,reason,cause)
  +                self.propagateErrorStateChange(state,reason,cause,message)
       
   
  -    def propagateErrorStateChange(self,state,reason,cause):
  +    def propagateErrorStateChange(self,state,reason,cause,message):
                  
           # .. then push this error down
           if hasattr(self,'getChildren'):
               for object in self.getChildren():
  -                object.changeState(state,reason,cause)        
  +                object.changeState(state,reason,cause,message)        
                               
       def setCause(self,cause):
           if not self.cause: self.cause=cause
  
  
  
  1.4       +0 -1      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.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- state.py	18 Nov 2003 03:57:47 -0000	1.3
  +++ state.py	19 Nov 2003 15:42:16 -0000	1.4
  @@ -63,7 +63,6 @@
   """
   
   from time import localtime, strftime, tzname
  -from string import lower, capitalize
   
   from gump.utils.launcher import *
   
  
  
  
  1.5       +1 -2      jakarta-gump/python/gump/model/ant.py
  
  Index: ant.py
  ===================================================================
  RCS file: /home/cvs/jakarta-gump/python/gump/model/ant.py,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- ant.py	18 Nov 2003 20:58:18 -0000	1.4
  +++ ant.py	19 Nov 2003 15:42:16 -0000	1.5
  @@ -63,7 +63,6 @@
   """
   
   from time import localtime, strftime, tzname
  -from string import lower, capitalize
   
   from gump.model.state import *
   from gump.model.note import *
  @@ -118,7 +117,7 @@
           # If the property is not as simple as srcdir
           if property.reference=="srcdir": return
           # If it isn't already a classpath dependency
  -        if project.hasFullDependencyOn(property.project): return
  +        if project.hasFullDependencyOnNamedProject(property.project): return
               
           # If there are IDs specified
           ids=''
  
  
  
  1.5       +72 -46    jakarta-gump/python/gump/model/project.py
  
  Index: project.py
  ===================================================================
  RCS file: /home/cvs/jakarta-gump/python/gump/model/project.py,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- project.py	18 Nov 2003 19:02:25 -0000	1.4
  +++ project.py	19 Nov 2003 15:42:16 -0000	1.5
  @@ -63,7 +63,6 @@
   """
   
   from time import localtime, strftime, tzname
  -from string import lower, capitalize
   
   from gump.model.state import *
   from gump.model.object import ModelObject, NamedModelObject, Jar
  @@ -277,15 +276,16 @@
           if self.totalDependees: return self.totalDependees
           
           for dependee in self.dependees:
  -            if not dependcee in self.totalDependees: 
  +            if not dependee in self.totalDependees: 
  +                # We have a new dependee
                   self.totalDependees.append(dependee)
  -                for subdependee in dependee.getProject().getFullDependeeProjects():
  +                for subdependee in dependee.getProject().getFullDependees():
                       if not subdependee in self.totalDependees:
                           self.totalDependees.append(subdependee)
           self.totalDependees.sort()
           
           # Store once
  -        return self.totalDependees
  +        return self.totalDependees            
                           
       def getFullDependeesCount(self):         
           return len(self.getFullDependees())             
  @@ -307,28 +307,22 @@
       def getFOGFactor(self):
           return self.getStats().getFOGFactor()
           
  -    def propagateErrorStateChange(self,state,reason,cause):
  -        # Do NOT over-write a preexisting condition
  -        if self.stateUnsetOrOk():
  -            
  -            #
  -            #
  -            #
  -            message = lower(stateName(state))
  -            if not REASON_UNSET == reason:
  -                message += " with reason " + lower(reasonString(reason))            
  -            self.addError(capitalize(message))
  -            
  -            #
  -            # Mark depend*ee*s as failed for this cause...
  -            # Warn option*ee*s
  -            #
  -            for dependee in self.dependees:
  +    def propagateErrorStateChange(self,state,reason,cause,message):
  +        
  +        #
  +        # Mark depend*ee*s as failed for this cause...
  +        # Warn option*ee*s
  +        #
  +        for dependee in self.getFullDependees():  
  +    
  +            # This is a backwards link, so use the owner
  +            dependeeProject=dependee.getOwnerProject()
  +        
  +            if dependee.isOptional():
  +                dependeeProject.addWarning("Optional dependency " + self.name + " " + message)
  +            else:
                   dependee.addError("Dependency " + self.name + " " + message)
  -                if dependee.isOptional():
  -                    dependee.getProject().addWarning("Optional dependency " + self.name
+ " " + message)
  -                else:
  -                    dependee.getProject().changeState(STATE_PREREQ_FAILED,reason,cause)
  +                dependeeProject.changeState(STATE_PREREQ_FAILED,reason,cause)
                                       
       #
       # We have a potential clash between the <project package attribute and
  @@ -433,50 +427,82 @@
                                   
                   # Add a dependency
                   self.addDependency(dependency)
  -                    
  -                # Add us as a dependee on them
  -                if not dependency in dependProject.dependees:
  -                    dependProject.dependees.append(dependency)
               else:
  -                badDepends.append(xmldepend)                
  -        
  +                badDepends.append(xmldepend)    
  +                
           # Walk the XML parts converting
           badOptions=[]
           for xmloption in self.xml.option:
               optionProjectName=xmloption.project
               if workspace.hasProject(optionProjectName):
                   optionProject=workspace.getProject(optionProjectName)
  -                
  +                                
  +                # Import the dependency
                   dependency=importXMLDependency(self, optionProject, xmloption, 1)
                                   
                   # Add a dependency
  -                self.addDependency(dependency)
  -                    
  -                # Add us as a dependee on them
  -                if not dependency in optionProject.dependees:
  -                    optionProject.dependees.append(dependency)
  +                self.addDependency(dependency)                    
               else:
                   badOptions.append(xmloption)
  -                
  +        
  +        #
  +        # Provide backwards links  [Note: ant might have added some
  +        # dependencies, so this is done here * not just with the direct
  +        # xml depend/option elements]
  +        #
  +        for dependency in self.getDependencies():
  +            dependProject=dependency.getProject()
  +            # Add us as a dependee on them
  +            dependProject.addDependee(dependency)  
                           
           return (badDepends, badOptions)
                                   
       def addDependency(self,dependency):
  +        #
  +        # TODO check this against any matching dependency
  +        # not equal?
  +        #
           if not dependency in self.depends:
  -            self.depends.append(dependency)
  +            if not dependency.getProject()==self:
  +                self.depends.append(dependency)
  +            #else:
  +            #    print 'Not Adding : ' + dependency
  +
  +    def addDependee(self,dependency):
  +        #
  +        # TODO check this against any matching dependency
  +        # not equal?
  +        #
  +        if not dependency in self.dependees:
  +            if not dependency.getOwnerProject()==self:
  +                self.dependees.append(dependency)
  +            #else:
  +            #    print 'Not Adding : ' + dependency
   
  +    # 
  +    def hasFullDependencyOnNamedProject(self,name):
  +        for dependency in self.depends:
  +            if dependency.getProject().getName()==name: return 1
  +# :TODO:        
  +#           and not dependency.noclasspath: return 1
  +#:TODO: noclasspath????
  +              
       # determine if this project is a prereq of any project on the todo list
  -    def hasFullDependencyOn(self,name):
  +    def hasDirectDependencyOn(self,project):
           for dependency in self.depends:
  -          if dependency.getProject().getName()==name: return 1
  -          
  +            if dependency.getProject()==project: return 1
  +    
  +    def hasDirectDependee(self,project):
  +        for dependee in self.dependees:
  +            if dependee.getOwnerProject()==project: return 1
  +            
  +    def hasDependee(self,project):
  +        for dependee in self.getFullDependees():
  +            if dependee.getOwnerProject()==project: return 1
  +            
       def getHomeDirectory(self):
           return self.home
           
  -# :TODO:        
  -#           and not dependency.noclasspath: return 1
  -#:TODO: noclasspath????
  -
       def inModule(self):
           return hasattr(self,'module') and self.module
           
  
  
  
  1.2       +6 -4      jakarta-gump/python/gump/model/depend.py
  
  Index: depend.py
  ===================================================================
  RCS file: /home/cvs/jakarta-gump/python/gump/model/depend.py,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- depend.py	17 Nov 2003 22:10:49 -0000	1.1
  +++ depend.py	19 Nov 2003 15:42:16 -0000	1.2
  @@ -125,25 +125,27 @@
       # :TODO: if same ids, but different order/spacing, it ought match..
       def __eq__(self,other):
           return 	self.project == other.project \
  +                and self.owner == other.owner	\
                   and self.inherit == other.inherit \
                   and self.runtime == other.runtime \
                   and self.ids == other.ids
                   
       def __cmp__(self,other):
           c = cmp(self.project,other.project)
  +        if not c: c = cmp(self.owner,other.owner)
           if not c: c = cmp(self.inherit,other.inherit)
           if not c: c = cmp(self.runtime,other.runtime)
           if not c: c = cmp(self.ids,other.ids)
           return c
       
       def __str__(self):
  -        output=self.project
  +        output=self.project.getName()
           if self.inherit:
  -            output+=' inherit="' + self.getInheritenceDescription() + '"'
  +            output+=' inherit=\'' + self.getInheritenceDescription() + '\''
           if self.runtime:
  -            output+=' runtime="' + self.runtime + '"'
  +            output+=' runtime=\'' + self.runtime + '\''
           if self.ids:
  -            output+=' ids="' + self.ids + '"'
  +            output+=' ids=\'' + self.ids + '\''
           return output
               
       def getOwnerProject(self):
  
  
  
  1.3       +9 -1      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.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- pyunit.py	18 Nov 2003 19:02:25 -0000	1.2
  +++ pyunit.py	19 Nov 2003 15:42:16 -0000	1.3
  @@ -78,8 +78,8 @@
       def raiseIssue(self, stuff):
           message=''
           for s in stuff:
  -            if message: message += '. '
               message += str(s)
  +            message += '. '
               
           raise RuntimeError, message
           
  @@ -96,9 +96,17 @@
           if not object1 == object2:
               self.raiseIssue(['Ought evaluate as equal', message, object1, object2])
               
  +    def assertNotEqual(self,message,object1,object2):
  +        if object1 == object2:
  +            self.raiseIssue(['Ought NOT evaluate as equal', message, object1, object2])
  +            
       def assertTrue(self,message,object):
           if not object:
               self.raiseIssue(['Ought evaluate as true', message, object])
  +            
  +    def assertFalse(self,message,object):
  +        if object:
  +            self.raiseIssue(['Ought evaluate as false', message, object])
               
       def assertIn(self,message,object,sequence):
           if not object in sequence:
  
  
  
  1.4       +18 -1     jakarta-gump/python/gump/test/model_tests.py
  
  Index: model_tests.py
  ===================================================================
  RCS file: /home/cvs/jakarta-gump/python/gump/test/model_tests.py,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- model_tests.py	18 Nov 2003 19:02:25 -0000	1.3
  +++ model_tests.py	19 Nov 2003 15:42:16 -0000	1.4
  @@ -67,6 +67,7 @@
   
   from gump import log
   import gump.config
  +from gump.model.state import *
   from gump.model.loader import WorkspaceLoader
   from gump.utils import *
   from gump.test import getWorkedTestWorkspace
  @@ -129,4 +130,20 @@
           module1=self.module1
           
           self.assertTrue('Module is CVS', module1.isCVS())
  -        self.assertNonZeroString('CVSROOT',module1.cvs.getCVSRoot())
  \ No newline at end of file
  +        self.assertNonZeroString('CVSROOT',module1.cvs.getCVSRoot())
  +        
  +    def testStatePropogation(self):
  +        module1=self.module1
  +        project1=self.project1
  +        project2=self.project2
  +        
  +        module1.changeState(STATE_FAILED)
  +        
  +        self.assertTrue('Project2 depends upon Project1', project2.hasDirectDependencyOn(project1))
  +        self.assertTrue('Project1 has Project2 as a Dependee', project1.hasDirectDependee(project2))
  +        self.assertFalse('Project1 ought NOT have Project1 as a Dependee', project1.hasDirectDependee(project1))
  +        
  +        self.assertEqual('State ought propagate down', project1.getState(), STATE_FAILED)
  +        self.assertEqual('State ought propagate to here', project2.getState(), STATE_PREREQ_FAILED)
  +        self.assertNotEqual('State ought NOT propagate like this', project2.getState(),
STATE_FAILED)
  +        
  \ No newline at end of file
  
  
  
  1.2       +0 -1      jakarta-gump/python/gump/document/resolver.py
  
  Index: resolver.py
  ===================================================================
  RCS file: /home/cvs/jakarta-gump/python/gump/document/resolver.py,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- resolver.py	17 Nov 2003 22:10:55 -0000	1.1
  +++ resolver.py	19 Nov 2003 15:42:16 -0000	1.2
  @@ -67,7 +67,6 @@
   import os
   import sys
   import logging
  -from string import lower,replace
   from xml.sax.saxutils import escape
   
   from gump import log
  
  
  
  1.3       +2 -0      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.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- nag.py	18 Nov 2003 03:57:47 -0000	1.2
  +++ nag.py	19 Nov 2003 15:42:16 -0000	1.3
  @@ -68,6 +68,8 @@
   import sys
   import logging
   
  +from string import lower, capitalize
  +
   from gump import log
   from gump.config import *
   from gump.model import *
  
  
  
  1.5       +2 -2      jakarta-gump/python/gump/output/rss.py
  
  Index: rss.py
  ===================================================================
  RCS file: /home/cvs/jakarta-gump/python/gump/output/rss.py,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- rss.py	18 Nov 2003 19:02:26 -0000	1.4
  +++ rss.py	19 Nov 2003 15:42:16 -0000	1.5
  @@ -95,7 +95,7 @@
       <link>http://jakarta.apache.org/gump/</link>
       <description>Life is like a box of chocolates</description>
   
  -    <admin:generatorAgent rdf:resource="http://cvs.apache.org/viewcvs/jakarta-gump/python/gump/rss.py"/>
  +    <admin:generatorAgent rdf:resource="http://cvs.apache.org/viewcvs/jakarta-gump/python/gump/output/rss.py"/>
       <admin:errorReportsTo rdf:resource="mailto:gump@jakarta.apache.org"/>
   
       <sy:updateFrequency>1</sy:updateFrequency>
  @@ -143,7 +143,7 @@
                                 <dc:subject>%s</dc:subject>
                                 <dc:date>%sT%s%s</dc:date>
                               </item>""" % \
  -                          (project.getName(),project.getStateDescriptionus(),datestr, link,
\
  +                          (project.getName(),project.getStateDescription(),datestr, link,
\
                                  content, \
                                  module.getName() + ":" + project.getName(), \
                                  datestr,timestr,TZ))
  
  
  

Mime
View raw message