gump-general mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From aj...@apache.org
Subject svn commit: rev 36578 - in gump/trunk/python/gump: build document/xdocs integration java model repository test update utils
Date Wed, 18 Aug 2004 20:20:59 GMT
Author: ajack
Date: Wed Aug 18 13:20:58 2004
New Revision: 36578

Modified:
   gump/trunk/python/gump/build/builder.py
   gump/trunk/python/gump/document/xdocs/documenter.py
   gump/trunk/python/gump/integration/depot.py
   gump/trunk/python/gump/java/helper.py
   gump/trunk/python/gump/model/depend.py
   gump/trunk/python/gump/model/module.py
   gump/trunk/python/gump/model/project.py
   gump/trunk/python/gump/model/propagation.py
   gump/trunk/python/gump/model/state.py
   gump/trunk/python/gump/repository/artifact.py
   gump/trunk/python/gump/repository/publisher.py
   gump/trunk/python/gump/test/artifacts.py
   gump/trunk/python/gump/update/artifact.py
   gump/trunk/python/gump/utils/work.py
Log:
First changes for 'building from repository' (and Depot download).

Modified: gump/trunk/python/gump/build/builder.py
==============================================================================
--- gump/trunk/python/gump/build/builder.py	(original)
+++ gump/trunk/python/gump/build/builder.py	Wed Aug 18 13:20:58 2004
@@ -58,6 +58,8 @@
 from gump.model.stats import *
 from gump.model.state import *
 
+import gump.integration.depot
+
 import gump.java.helper
 
 
@@ -100,58 +102,52 @@
         # :TODO: Code this nicer, perhaps...    
         if project.isPackaged():             
             self.performProjectPackageProcessing(project, languageHelper, stats)
-            return
-                
-        # Do this even if not ok
-        self.performPreBuild(project, languageHelper, stats)
+        else:
+            # Do this even if not ok
+            self.performPreBuild(project, languageHelper, stats)
 
-        if project.okToPerformWork():        
-            log.debug('Performing Build Upon: [' + `project.getPosition()` + '] ' + project.getName())
+            if project.okToPerformWork():        
+                log.debug('Performing Build Upon: [' + `project.getPosition()` + '] ' + project.getName())
 
-            # Turn on --verbose or --debug if failing ...
-            if stats:
-                if (not STATE_SUCCESS == stats.currentState) and \
-                        not project.isVerboseOrDebug():
-                    if stats.sequenceInState > SIGNIFICANT_DURATION:
-                        project.addInfo('Enable "debug" output, due to a sequence of %s previous
errors.' % stats.sequenceInState)
-                        project.setDebug(True)
-                    else:
-                        project.addInfo('Enable "verbose" output, due to %s previous error(s).'
% stats.sequenceInState)    
-                        project.setVerbose(True)
-
-            # Pick your poison..
-            if project.hasScript():
-                self.script.buildProject(project, languageHelper, stats)
-            elif project.hasAnt():
-                self.ant.buildProject(project, languageHelper, stats)
-            elif project.hasMaven():
-                self.maven.buildProject(project, languageHelper, stats)
-            
-            if not project.okToPerformWork() and not project.isDebug():
-                # Display...
-                project.addInfo('Enable "debug" output, due to build failure.')
-                project.setDebug(1)
-                    
-        # Do this even if not ok
-        self.performPostBuild( project, languageHelper, stats )
+                # Turn on --verbose or --debug if failing ...
+                #if stats:
+                #    if (not STATE_SUCCESS == stats.currentState) and \
+                #            not project.isVerboseOrDebug():
+                #        if stats.sequenceInState > SIGNIFICANT_DURATION:
+                #            project.addInfo('Enable "debug" output, due to a sequence of
%s previous errors.' % stats.sequenceInState)
+                #            project.setDebug(True)
+                #        else:
+                #            project.addInfo('Enable "verbose" output, due to %s previous
error(s).' % stats.sequenceInState)    
+                #            project.setVerbose(True)
+
+                # Pick your poison..
+                if project.hasScript():
+                    self.script.buildProject(project, languageHelper, stats)
+                elif project.hasAnt():
+                    self.ant.buildProject(project, languageHelper, stats)
+                elif project.hasMaven():
+                    self.maven.buildProject(project, languageHelper, stats)
+              
+            # Do this even if not ok
+            self.performPostBuild( project, languageHelper, stats )
+        
+            # If not ok, we might have some artifacts in the repository that
+            # are of value...
+            if not project.okToPerformWork() and project.hasOutputs():
+                self.extractFromRepository(project, languageHelper)
     
-        if project.isFailed():
-            log.warn('Failed to build project #[' + `project.getPosition()` + '] : [' + project.getName()
+ '], state:' \
-                    + project.getStateDescription())                                    
         
+            if project.isFailed():
+                log.warn('Failed to build project #[' + `project.getPosition()` + '] : ['
+ project.getName() + '], state:' \
+                        + project.getStateDescription())                                
             
 
     def performDelete(self,project,delete,index=0):
-        """ Perform the delete command for a <delete entry """
-        
-        return
+        """ 
+        Perform the delete command for a <delete entry 
         
-        # :TODO: Re-instate this some time, when can delete
-        # non-empty directories.
+        no Return
+        """
         
-        basedir=os.path.abspath(project.getModule().getWorkingDirectory() or dir.base)
-    
-        #
         # Delete a directory and/or a file
-        #
         if delete.hasDirectory():
             dir=delete.getDirectory()
             try:
@@ -195,9 +191,12 @@
             project.addError('   <mkdir without \'dir\' attribute.')
             raise RuntimeError('Bad <mkdir, missing \'dir\' attribute')
                
-    def performPreBuild( self, project, language, stats ):
+    def performPreBuild( self, project, languageHelper, stats ):
+        
         """ 
         	Perform pre-build Actions 
+        	
+        	No return.
         """
        
         log.debug(' ------ Performing pre-Build Actions (mkdir/delete) for : '+ project.getName())
@@ -235,11 +234,12 @@
         if startedOk and not project.okToPerformWork():
             log.warn('Failed to perform pre-build on project [' + project.getName() + ']')
 
-    def performPostBuild(self, project, language, stats):
+    def performPostBuild(self, project, languageHelper, stats):
         """
         	Perform Post-Build Actions
+        	
+        	No return.
         """
-     
         log.debug(' ------ Performing post-Build Actions (check jars) for : '+ project.getName())
 
         if project.okToPerformWork():
@@ -247,7 +247,7 @@
                 outputs = []
                     
                 # Ensure the jar output were all generated correctly.
-                outputsOk=1
+                outputsOk=True
                 for jar in project.getJars():
                     jarPath=os.path.abspath(jar.getPath())
                     # Add to list of outputs, in case we
@@ -268,7 +268,7 @@
                                           
                         # Add to list of outputs, in case we
                         # fail to find, and need to go list 
-                        # directoiries
+                        # directories
                         outputs.append(licensePath)
                             
                         if not os.path.exists(licensePath):
@@ -319,7 +319,7 @@
                 catDirectoryContentsToFileHolder(project, reportDir, FILE_TYPE_OUTPUT)
     
                         
-    def performProjectPackageProcessing(self, project, language, stats):
+    def performProjectPackageProcessing(self, project, languageHelper, stats):
         """
         	Perform Package Processing Actions
         """
@@ -394,7 +394,75 @@
                 # List them, why not...
                 listDirectoryToFileHolder(project,project.getHomeDirectory(),
                     FILE_TYPE_PACKAGE, 'list_package_'+project.getName())               
                                   
+
+    def extractFromRepository(self, project, languageHelper):
+        """
+            If failed to build, see if we have a copy in the repo...
+            
+            No return.
+        """
         
+        if not project.hasOutputs(): return
+     
+        log.info(' ------ Attempt Repository Search for : '+ project.getName())
+
+        # See if we have any...
+        artifacts = self.repository.extractMostRecentGroup(project.getArtifactGroup())
+        if not artifacts:
+            self.checkUpstreamRepositories(project)
+            # Then try again...
+            artifacts = self.repository.extractMostRecentGroup(project.getArtifactGroup())
+            
+        
+        # :TODO:
+        # If not artifacts, download using Depot?
+        
+        artifactsOk=True
+            
+        if artifacts:       
+        
+            # See if we can use 'stored' artifacts.
+            for jar in project.getJars():
+                id = jar.getId()
+                
+                # Use the repository one...
+                if artifacts.has_key(id):
+                    (aid,date,extn,path)=artifacts[id]                
+                    
+                    log.info('Utilize %s from Gump artifact repository for id' % (path, id))
+                    
+                    # Stash this fallback...
+                    jar.setPath(path)
+                else:
+                    log.info('Failed to find artifact for id %s (Gump Repo has %s)' % \
+                            (id, artifact.keys()))
+                            
+                    artifactsOk=False
+                    break
+                    
+            if artifactsOk:
+                log.debug(' ------ Extracted (fallback) artifacts from Repository : '+ project.getName())
                                       
+       
+    def checkUpstreamRepositories(self,project):
+        """
+        
+        See if we can download something...
+        
+        """
+        if self.run.getEnvironment().noDepot: return
+        
+        log.info(' ------ Check upstream repositories for : '+ project.getName())    
+        
+        cmd=gump.integration.depot.getGroupUpdateCommand(project.getArtifactGroup(),
+                    self.repository.getRepositoryDir())
+        
+        # Execute the command ....
+        cmdResult=execute(cmd,self.run.getWorkspace().tmpdir)
+    
+        # Update context with the fact that this work was done
+        work=CommandWorkItem(WORK_TYPE_UPDATE,cmd,cmdResult)
+        project.performedWork(work)
+         
     def preview(self,project,languageHelper):
         """
         Preview what a build would do.

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 Aug 18 13:20:58 2004
@@ -360,9 +360,22 @@
         
         optTable=optSection.createTable(['Name','Value'])
         opts=0
+               
+        descs={ 'Build':'Perform Build',
+                'XDocs':'Generate XDOCS',
+                'Statistics':'Update Statistics (to database)',
+                'Verbose':'Verbose Run',
+                'Cache':'Cache metadata (don\'t go to remote source)',
+                'Text':'Text Output',
+                'Official':'Official Run (e.g. nag notifies, etc.)',
+                'Results':'Generate Results' }
+                
         # iterate over this suites properties
         for (name,value) in getBeanAttributes(options).items():
-            optTable.createEntry(name,value)
+            desc=name
+            if descs.has_key(name):
+                desc = descs[name] + ' (' + name + ')'                
+            optTable.createEntry(desc,value)
             opts+=1
             
         if not opts: optTable.createEntry('None')
@@ -375,24 +388,13 @@
         envSection=document.createSection('Gump Environment')
         envSection.createParagraph(
             """The environment that this Gump run was within.""")     
-        
-        descs={ 'Build':'Perform Build',
-                'XDocs':'Generate XDOCS',
-                'Statistics':'Update Statistics (to database)',
-                'Verbose':'Verbose Run',
-                'Cache':'Cache metadata (don\'t go to remote source)',
-                'Text':'Text Output',
-                'Official':'Official Run (e.g. nag notifies, etc.)',
-                'Results':'Generate Results' }
+ 
         propertiesSection=envSection.createSection('Properties')
         envTable=propertiesSection.createTable(['Name/Description','Value'])
         envs=0
         # iterate over this suites properties
         for (name,value) in getBeanAttributes(environment).items():
-            desc=name
-            if descs.has_key(name):
-                desc = descs[name] + ' (' + name + ')'
-            envTable.createEntry(desc,str(value))
+            envTable.createEntry(name,str(value))
             envs+=1            
         if not envs: envTable.createEntry('None')
         
@@ -1758,12 +1760,11 @@
                                                       
         # Display nag information
         if project.hasNotifys():
-            if project.isVerboseOrDebug():
-                for pair in project.getNotifys():
-                    toaddr=pair.getToAddress()
-                    fromaddr=pair.getFromAddress()
-                    detailsList.createEntry('Notify To: ').createFork('mailto:'+toaddr,toaddr)
-                    detailsList.createEntry('Notify From: ').createFork('mailto:'+fromaddr,fromaddr)
+            for pair in project.getNotifys():
+                toaddr=pair.getToAddress()
+                fromaddr=pair.getFromAddress()
+                detailsList.createEntry('Notify To: ').createFork('mailto:'+toaddr,toaddr)
+                detailsList.createEntry('Notify From: ').createFork('mailto:'+fromaddr,fromaddr)
                     
         elif not project.isPackaged() and project.hasBuilder():            
             document.createWarning('This project does not utilize Gump notification.')  

Modified: gump/trunk/python/gump/integration/depot.py
==============================================================================
--- gump/trunk/python/gump/integration/depot.py	(original)
+++ gump/trunk/python/gump/integration/depot.py	Wed Aug 18 13:20:58 2004
@@ -23,6 +23,8 @@
 from gump import log
 from gump.core.config import *
 
+import gump.process.command
+
 def getDepotHome(visual=True):
     if os.environ.has_key('DEPOT_UPDATE_HOME'):        
         return os.environ['DEPOT_UPDATE_HOME']
@@ -37,6 +39,28 @@
 def getDepotUpdateCmd():
     return sys.executable+' '+getDepotUpdatePath()+' update'
     
+def getGroupUpdateCommand(group,repository):
+    """
+    	Create the Depot command line for updating this group
+    	from an upstream repository.    	
+    """
+        
+    log.debug("Artifact Update Group: " + group)
+
+    # Prepare Artifact checkout/update command...
+    cmd=gump.process.command.Cmd(getDepotUpdateCmd(), 'update_'+group, repository)
+        
+    # Group (mandatory)
+    cmd.addParameter('-g',group)
+    
+    # Group (mandatory, if no URL)
+    cmd.addParameter('-rs','gump')
+        
+    # Target
+    cmd.addParameter('-t')
+    cmd.addParameter(repository)  
+   
+    return cmd    
     
 
 

Modified: gump/trunk/python/gump/java/helper.py
==============================================================================
--- gump/trunk/python/gump/java/helper.py	(original)
+++ gump/trunk/python/gump/java/helper.py	Wed Aug 18 13:20:58 2004
@@ -43,7 +43,7 @@
         
         # Caches for classpaths
         self.classpaths={}
-        self.bootclasspaths={}
+        self.bootclasspaths={}       
         
     def getJVMArgs(self,project):
         
@@ -63,9 +63,7 @@
         # Calculate classpath and bootclasspath
         (classpath, bootclasspath) = self.getClasspathObjects(project,debug)
         
-        #
         # Return them simple/flattened
-        #
         return ( classpath.getFlattened(), bootclasspath.getFlattened() )
 
    
@@ -74,6 +72,8 @@
         
         The basic classpath needs to include a compiler...
         
+        Return a system classpath (to include $JAVA_HOME/lib/tools.jar'
+        for a compiler).
         """
         sysClasspath=gump.java.cp.Classpath('System Classpath')
         javaHome=self.run.getEnvironment().getJavaHome()
@@ -186,7 +186,12 @@
             dependStr += 'Runtime'
   
         # Append JARS for this project
-        #    (respect ids)
+        #    (respect ids --- none means 'all)
+        ####################################################
+        # Note, if they don't come from the project outputs
+        # (e.g. 'cos the project failed) attempt to get them
+        # from the repository. [This has been done already,
+        # so is transparent here.]
         projectIds=[]
         for jar in project.getJars():
             # Store for double checking

Modified: gump/trunk/python/gump/model/depend.py
==============================================================================
--- gump/trunk/python/gump/model/depend.py	(original)
+++ gump/trunk/python/gump/model/depend.py	Wed Aug 18 13:20:58 2004
@@ -441,11 +441,9 @@
         
     def buildDependenciesMap(self,workspace):        
         
-        #
         # Provide backwards links  [Note: ant|maven might have added some
         # dependencies, so this is done here & not just with the direct
         # xml depend/option elements]
-        #
         for dependency in self.getDirectDependencies():
             dependProject=dependency.getProject()
             # Add us as a dependee on them
@@ -457,6 +455,14 @@
             if dependency.getProject().getName()==name	\
                 and not dependency.isNoClasspath() :
                 return True            
+        return False
+
+    def uponFuzzy(self):
+        """
+        At least one of these dependencies is Fuzzy...
+        """
+        for dependency in self.getFullDependencies():
+            if dependency.getProject().isFuzzy(): return True
         return False
 
     # determine if this project is a prereq of any project on the todo list

Modified: gump/trunk/python/gump/model/module.py
==============================================================================
--- gump/trunk/python/gump/model/module.py	(original)
+++ gump/trunk/python/gump/model/module.py	Wed Aug 18 13:20:58 2004
@@ -432,6 +432,15 @@
     def getNotifys(self):
         return self.notifys
         
+    def getArtifactGroup(self):
+        """
+        What does this projects artifacts group under?
+        Right now ... the module name
+        
+        Return String
+        """
+        return self.getName()
+        
     def addProject(self,project):
         """
         	Associate this module with this project, and vice verse.

Modified: gump/trunk/python/gump/model/project.py
==============================================================================
--- gump/trunk/python/gump/model/project.py	(original)
+++ gump/trunk/python/gump/model/project.py	Wed Aug 18 13:20:58 2004
@@ -120,6 +120,15 @@
                 return self.module.getNotifys()
         return self.notifys
         
+    def getArtifactGroup(self):
+        """
+        What does this projects artifacts group under?
+        Ask the module...
+        
+        Return String
+        """
+        return self.getModule().getArtifactGroup()
+        
     def hasAnt(self):
         if self.ant: return True
         return False

Modified: gump/trunk/python/gump/model/propagation.py
==============================================================================
--- gump/trunk/python/gump/model/propagation.py	(original)
+++ gump/trunk/python/gump/model/propagation.py	Wed Aug 18 13:20:58 2004
@@ -54,9 +54,7 @@
                 # List of things that caused issues...
                 self.addCause(cause)
                                    
-                #
                 # Describe the problem
-                #
                 if not message:
                     message = lower(stateDescription(state))
                     if not REASON_UNSET == reason:

Modified: gump/trunk/python/gump/model/state.py
==============================================================================
--- gump/trunk/python/gump/model/state.py	(original)
+++ gump/trunk/python/gump/model/state.py	Wed Aug 18 13:20:58 2004
@@ -24,14 +24,16 @@
 STATE_NONE=1
 STATE_SUCCESS=2
 STATE_FAILED=3
-STATE_STALE=4
+STATE_STALE_SUCCESS=4
+STATE_STALE_FAILED=5
+STATE_FUZZY_SUCCESS=5
+STATE_FUZZY_FAILED=4
 STATE_PREREQ_FAILED=5
 STATE_COMPLETE=6
 
 stateNames = { STATE_UNSET : "Unset",
            STATE_NONE : "NoWork",
            STATE_SUCCESS : "Success",
-           STATE_STALE : "Stale",
            STATE_FAILED : "Failed",
            STATE_PREREQ_FAILED : "PrereqFailed",
            STATE_COMPLETE : "Complete" }
@@ -40,7 +42,6 @@
            STATE_NONE : "No Work Performed",
            STATE_SUCCESS : "Success",
            STATE_FAILED : "Failed",
-           STATE_STALE : "Stale",
            STATE_PREREQ_FAILED : "Prerequisite Failed",
            STATE_COMPLETE : "Complete" }
 
@@ -54,7 +55,6 @@
            "NoWork" : STATE_NONE,
             "Success" : STATE_SUCCESS,
             "Failed" : STATE_FAILED,
-            "Stale" : STATE_STALE,
             "PrereqFailed" : STATE_PREREQ_FAILED,
             "Complete"  : STATE_COMPLETE}
             
@@ -62,7 +62,6 @@
            "No Work Performed" : STATE_NONE,
             "Success" : STATE_SUCCESS,
             "Failed" : STATE_FAILED,
-            "Stale" : STATE_STALE,
             "Prerequisite Failed" : STATE_PREREQ_FAILED,
             "Complete"  : STATE_COMPLETE}
            
@@ -185,9 +184,7 @@
         if self.isReasonUnset(): return ''
         return reasonDescription(self.getReason())
         
-    #
-    #
-    #
+    # Simple Tests
     def isSuccess(self):
         return STATE_SUCCESS == self.state
                 
@@ -196,7 +193,7 @@
                 
     def isFailed(self):
         return STATE_FAILED == self.state
-        
+ 
     def isPrereqFailed(self):
         return STATE_PREREQ_FAILED == self.state
                 
@@ -211,11 +208,14 @@
         return self.isUnset() or self.isOk()           
 
     def isOk(self):
-        return self.isSuccess() or self.isComplete()   
+        return self.isSuccess() or self.isComplete()
 
     def isNotOk(self):
-        return self.isFailed() or self.isPrereqFailed()
-               
+        return self.isFailed() 
+
+    def okToPerformWork(self):
+        return self.isUnsetOrOk() or self.isPrereqFailed()
+        
 class Stateful:
     def __init__(self):  
         """
@@ -241,8 +241,7 @@
         return self.statePair.getStateDescription()
         
     def hasReason(self):
-        if self.statePair.isReasonUnset(): return 0
-        return 1
+        return self.statePair.isReasonUnset()
         
     def getReason(self):
         return self.statePair.reason
@@ -276,4 +275,8 @@
 
     def isNotOk(self):
         return self.statePair.isNotOk() 
+        
+    def okToPerformWork(self):
+        return self.statePair.okToPerformWork() 
+        
                

Modified: gump/trunk/python/gump/repository/artifact.py
==============================================================================
--- gump/trunk/python/gump/repository/artifact.py	(original)
+++ gump/trunk/python/gump/repository/artifact.py	Wed Aug 18 13:20:58 2004
@@ -27,8 +27,13 @@
 
 from shutil import copyfile
 
+import re
 
 class ArtifactRepository:
+    
+    # Match {id}-gump-{date}.{extn} id=1, date=2, extn=3
+    ARTIFACT_RE=re.compile(r'^(.*)-gump-([0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]).(.*)$')
+    
     """
     	Represents a local (Gump produced) Artifacts Repository
     """
@@ -57,12 +62,13 @@
         if not os.path.exists(rdir): os.makedirs(rdir)
         return rdir  
     
-    #
-    # Repository format is:
-    #
-    #	../{group}/jars/{output files}
-    #    
-    def getGroupDir(self,group,rdir=None):
+    def _getGroupDir(self,group,rdir=None):
+        """    
+        	Repository format is:
+    
+    		.../{group}/jars/{output files}
+        
+        """
         if not rdir: rdir=self.getRepositoryDir()
         gdir=os.path.abspath(os.path.join(rdir,group))
         if not os.path.exists(gdir): os.makedirs(gdir)
@@ -70,10 +76,38 @@
         if not os.path.exists(jdir): os.makedirs(jdir)
         return jdir  
         
+    def getGroups(self):
+        """
+        Get all groups in the repository
+        """
+        return os.path.listdir(getRepositoryDir())
+        
+    def cleanRepository(self):
+        for group in self.getGroups():
+            try:
+                self.cleanRepositoryGroup(group)
+            except:
+                pass
+                
+    def cleanRepositoryGroup(self,group):
+        recent=self.extractMostRecentGroup(group)
+        if recent:
+            
+            # Locate (and make if needed) group.
+            gdir=self._getGroupDir(group)   
+        
+            for file in os.listdir(gdir):
+                match=ArtifactRepository.ARTIFACT_RE.match(file)
+                if match and not match.group(1) in recent.keys():
+                    print 'remove : ' + file
+                    
     def publish(self,group,artifact,id=None):
+        """
+        Publish an artifact ot the artifact repository.
+        """
         
         # Locate (and make if needed) group.
-        cdir=self.getGroupDir(group)
+        gdir=self.getGroupDir(group)
         
         # Extract name, to make relative to group
         artifactName=os.path.basename(artifact)
@@ -86,10 +120,57 @@
             (artifactRoot, artifactExtn) = os.path.splitext(artifactName)
             artifactName=id + '-gump-' + default.date_s + artifactExtn
         
-        newArtifact=os.path.join(cdir,artifactName)
+        newArtifact=os.path.join(gdir,artifactName)
         
         # Do the file transfer..
         copyfile(artifact,newArtifact)
         
         log.info('Published %s to repository as %s at %s' % (artifact,artifactName, newArtifact))
+        
+        
+    def extractGroup(self,group):
+        """
+        Get all the sets of identifiers in this group
+        
+        Returns a tuple:
+        
+        1) map of list of tuples (id,date,extn,full name), keyed by date (string).
+        2) the latest date (most recent)
+        
+        """
+        
+        # Locate (and make if needed) group.
+        gdir=self._getGroupDir(group)   
+        
+        # See what we have
+        dates={}
+        mostRecent=''
+        for file in os.listdir(gdir):    
+            match=ArtifactRepository.ARTIFACT_RE.match(file) 
+            if match:
+                # Extract the pieces....
+                id=match.group(1)
+                date=match.group(2)
+                extn=match.group(3)
+                
+                # Group by date 
+                if not dates.has_key(date):
+                    dates[date]={}
+                dates[date][id]=(id,date,extn,match.group(0))
+                
+                # Keep track of latest...
+                if date > mostRecent:
+                    mostRecent=date
+                 
+        return (dates, mostRecent)
+        
+    def extractMostRecentGroup(self,group):
+         """
+         Get the newest set
+         
+         Returns a list of tuples (id,date,extn,full name)
+         """
+         (dates,mostRecent)=self.extractGroup(group)
+         if dates: return dates[mostRecent]
+         
         

Modified: gump/trunk/python/gump/repository/publisher.py
==============================================================================
--- gump/trunk/python/gump/repository/publisher.py	(original)
+++ gump/trunk/python/gump/repository/publisher.py	Wed Aug 18 13:20:58 2004
@@ -47,7 +47,7 @@
         """
         
         if project.okToPerformWork() and project.hasOutputs() and project.isRedistributable():
     
-            groupName = project.getModule().getName()
+            groupName = project.getArtifactGroup() 
             
             # If we have a <license name='...
             if project.hasLicense():
@@ -80,5 +80,13 @@
                                    self.repository.getGroupDir(groupName),
                                    gump.utils.file.FILE_TYPE_REPO, 
                                    'list_repo_'+project.getName())
+                                   
+        else:
+            ok = project.okToPerformWork()
+            has = project.hasOutputs()
+            redist = project.isRedistributable()
+        
+            log.debug('Not publishing because [ok=%s,has outputs=%s,redistributable=%s]'
\
+                        % (ok,has,redist))
         
   

Modified: gump/trunk/python/gump/test/artifacts.py
==============================================================================
--- gump/trunk/python/gump/test/artifacts.py	(original)
+++ gump/trunk/python/gump/test/artifacts.py	Wed Aug 18 13:20:58 2004
@@ -62,4 +62,40 @@
     def testPublisher(self):
         p=gump.repository.publisher.RepositoryPublisher(self.run)
         p.processProject(self.workspace.getProject('project1'))
-            
\ No newline at end of file
+            
+    def testRepositoryExtract(self):
+        # Create a repository & populate it
+        self.repo=gump.repository.artifact.ArtifactRepository(self.testRepo)   
+        self.testPublishJar()
+         
+        (dated, latest)=self.repo.extractGroup('testGroup')
+        
+        self.assertNotNone('Extracted something', dated)
+        self.assertNotEmpty('Extracted something', dated)
+        
+    def testRepositoryExtract2(self):
+        # Create a repository & populate it
+        self.repo=gump.repository.artifact.ArtifactRepository(self.testRepo)   
+        
+        gdir=self.repo._getGroupDir('test')
+        
+        file(os.path.join(gdir,'id1-gump-20030221.jar'),'w').close()
+        file(os.path.join(gdir,'id1-gump-20040221.jar'),'w').close()
+        file(os.path.join(gdir,'id1-gump-20050221.jar'),'w').close()
+        file(os.path.join(gdir,'id2-gump-20030221.jar'),'w').close()
+        file(os.path.join(gdir,'id2-gump-20040221.jar'),'w').close()
+        file(os.path.join(gdir,'id2-gump-20050221.jar'),'w').close()
+        file(os.path.join(gdir,'id3-gump-20030221.jar'),'w').close()
+        file(os.path.join(gdir,'id3-gump-20040221.jar'),'w').close()
+        file(os.path.join(gdir,'id3-gump-20050221.jar'),'w').close()
+        file(os.path.join(gdir,'id4-gump-20050221.jar'),'w').close()
+        
+        (dated, latest)=self.repo.extractGroup('test')
+        
+        import pprint
+        pprint.pprint(dated)
+        
+        self.assertNotNone('Extracted something', dated)
+        self.assertEqual('Extracted correct groups', len(dated.keys()), 3)
+        self.assertEqual('Detected correct latest', latest, '20050221')
+        
\ No newline at end of file

Modified: gump/trunk/python/gump/update/artifact.py
==============================================================================
--- gump/trunk/python/gump/update/artifact.py	(original)
+++ gump/trunk/python/gump/update/artifact.py	Wed Aug 18 13:20:58 2004
@@ -111,8 +111,8 @@
         #
         # Prepare Artifact checkout/update command...
         # 
-        cmd=Cmd(getDepotUpdateCmd(),	\
-                'update_'+module.getName(),	\
+        cmd=Cmd(getDepotUpdateCmd(),
+                'update_'+module.getName(),
                 module.getWorkspace().cvsdir)
         
         # Be 'quiet' (but not silent) unless requested otherwise.

Modified: gump/trunk/python/gump/utils/work.py
==============================================================================
--- gump/trunk/python/gump/utils/work.py	(original)
+++ gump/trunk/python/gump/utils/work.py	Wed Aug 18 13:20:58 2004
@@ -277,10 +277,7 @@
         return self.worklist
         
     def performedWork(self,item):
-    	self.worklist.add(item)   
-        	
-    def okToPerformWork(self):
-        return self.isUnset() or self.isSuccess()        
+    	self.worklist.add(item)           	
     
     def hasStart(self):
         return self.worklist.hasStart()

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


Mime
View raw message