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 resolver.py forrest.py
Date Sat, 06 Dec 2003 18:01:48 GMT
ajack       2003/12/06 10:01:48

  Modified:    python/gump engine.py gumprun.py integrate.py
               python/gump/model workspace.py
               python/gump/syndication rss.py syndicator.py
               python/gump/document resolver.py forrest.py
  Log:
  1) More syndication consolidation/content tweaks
  2) First whack at --dated (to add date to log dir)
  
  Revision  Changes    Path
  1.39      +8 -0      jakarta-gump/python/gump/engine.py
  
  Index: engine.py
  ===================================================================
  RCS file: /home/cvs/jakarta-gump/python/gump/engine.py,v
  retrieving revision 1.38
  retrieving revision 1.39
  diff -u -r1.38 -r1.39
  --- engine.py	5 Dec 2003 01:01:52 -0000	1.38
  +++ engine.py	6 Dec 2003 18:01:48 -0000	1.39
  @@ -65,7 +65,15 @@
           workspace = run.getWorkspace()
           
           #
  +        #
  +        #
           workspace.checkEnvironment(exitOnError)
  +        
  +        #
  +        # Modify the log on the fly, if --dated
  +        #
  +        if run.getOptions().isDated():
  +            workspace.setDatedDirectories()
           
           #
           # Use forrest if available...
  
  
  
  1.6       +10 -8     jakarta-gump/python/gump/gumprun.py
  
  Index: gumprun.py
  ===================================================================
  RCS file: /home/cvs/jakarta-gump/python/gump/gumprun.py,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- gumprun.py	1 Dec 2003 17:34:07 -0000	1.5
  +++ gumprun.py	6 Dec 2003 18:01:48 -0000	1.6
  @@ -300,17 +300,11 @@
       def __init__(self):
           self.optimize=0
    
  -        #
  -        # Turns on ant '-debug'
  -        #
           self.debug=0	
  -        
  -        #
  -        # Turns on ant '-verbose'
  -        #
           self.verbose=0	
  +        self.dated=0	# Defaults to NOT dated.
           
  -        
  +        # Default is Text        
           self.documenter=TextDocumenter()
   
       def setDocumenter(self, documenter):
  @@ -319,8 +313,16 @@
       def getDocumenter(self):
           return self.documenter
   
  +    # Different Documenter have different resolvers 'cos
  +    # they may vary the layout
       def getResolver(self):
           return self.getDocumenter().getResolver(self)
  +        
  +    def isDated(self):
  +        return self.dated
  +        
  +    def setDated(self,dated):
  +        self.dated=dated
           
   class GumpRun(Workable,Annotatable,Stateful):
       def __init__(self,workspace,expr=None,options=None):
  
  
  
  1.17      +6 -12     jakarta-gump/python/gump/integrate.py
  
  Index: integrate.py
  ===================================================================
  RCS file: /home/cvs/jakarta-gump/python/gump/integrate.py,v
  retrieving revision 1.16
  retrieving revision 1.17
  diff -u -r1.16 -r1.17
  --- integrate.py	24 Nov 2003 18:32:19 -0000	1.16
  +++ integrate.py	6 Dec 2003 18:01:48 -0000	1.17
  @@ -44,21 +44,15 @@
       # get parsed workspace definition
       workspace=WorkspaceLoader().load(ws)
         
  -    #
  -    # Check Environment (eventually not do this each time)
  -    # Exit if problems...
  -    #
  -    #checkEnvironment(workspace,context,1)
  -        
  -    #
  -    # Check projects (and such) in workspace...
  -    # Store results in context, do not display
  -    # to screen.
  -    #
  -    #check(workspace, ps, context, 0)    
       
       # TODO populate...
       options=GumpRunOptions()
  +  
  +    #
  +    # Dated means add the date to the log dir...
  +    #
  +    if '-d' in args or '--dated' in args:
  +        options.setDated(1)
       
       # The Run Details...
       run=GumpRun(workspace,ps,options)
  
  
  
  1.15      +63 -47    jakarta-gump/python/gump/model/workspace.py
  
  Index: workspace.py
  ===================================================================
  RCS file: /home/cvs/jakarta-gump/python/gump/model/workspace.py,v
  retrieving revision 1.14
  retrieving revision 1.15
  diff -u -r1.14 -r1.15
  --- workspace.py	26 Nov 2003 16:08:39 -0000	1.14
  +++ workspace.py	6 Dec 2003 18:01:48 -0000	1.15
  @@ -163,8 +163,6 @@
       def getSortedProjects(self):
           return self.sortedProjects       
           
  -        
  -        
       def complete(self, xmlprofiles, xmlrepositories, xmlmodules, xmlprojects):        
           if self.isComplete(): return
           
  @@ -181,53 +179,9 @@
               self.bannerLink="http://jakarta.apache.org"
           else:
               self.bannerLink=self.xml['banner-link']
  -    
  -        # Construct tmp on demand
  -        if not self.xml.tmpdir: 
  -            self.tmpdir=os.path.join(self.getBaseDirectory(),"tmp")
  -        else:
  -            self.tmpdir=self.xml.tmpdir
  -            
  -        if not os.path.exists(self.tmpdir): 
  -            print "TMPDIR: " + self.tmpdir
  -            os.makedirs(self.tmpdir)    
  -    
  -        # Construct logdir on demand
  -        if not self.xml.logdir: 
  -            self.logdir=os.path.join(self.getBaseDirectory(),"log")
  -        else:
  -            self.logdir=self.xml.logdir
  -        
  -        if not os.path.exists(self.logdir): os.makedirs(self.logdir)
  -    
  -        # Construct repository dir on demand
  -        if not self.xml.jardir: 
  -            self.jardir=os.path.join(self.getBaseDirectory(),"repo")
  -        else:
  -            self.jardir=self.xml.jardir
  -                
  -        if not os.path.exists(self.jardir): os.makedirs(self.jardir)
  -    
  -        # Construct CVS directory on demand
  -        if not self.xml.cvsdir: 
  -            self.cvsdir=os.path.join(self.getBaseDirectory(),"cvs")
  -        else:
  -            self.cvsdir=self.xml.cvsdir
   
  -        if not os.path.exists(self.cvsdir): os.makedirs(self.cvsdir)
  -    
  -        # Package Dir Ought Exist
  -        if not self.xml.pkgdir: 
  -            self.pkgdir=self.getBaseDirectory()
  -        else:
  -            self.pkgdir=self.xml.pkgdir
  +        self.completeDirectories()
           
  -        if self.xml.deliver:
  -            if not self.xml.scratchdir: 
  -                self.scratchdir=os.path.join(self.getBaseDirectory(),"scratch")
  -            else:
  -                self.scratchdir=self.xml.scratchdir
  -
           # Allow per workspace overrides
       
           if not self.xml.logurl: 
  @@ -352,6 +306,68 @@
           self.sortedRepositories=createOrderedList(self.getRepositories())
           
           self.setComplete(1)
  +
  +    def completeDirectories(self):
  +            
  +        # Construct tmp on demand
  +        if not self.xml.tmpdir: 
  +            self.tmpdir=os.path.join(self.getBaseDirectory(),"tmp")
  +        else:
  +            self.tmpdir=self.xml.tmpdir
  +            
  +        if not os.path.exists(self.tmpdir): 
  +            os.makedirs(self.tmpdir)    
  +    
  +        # Construct logdir on demand
  +        if not self.xml.logdir: 
  +            self.logdir=os.path.join(self.getBaseDirectory(),"log")
  +        else:
  +            self.logdir=self.xml.logdir
  +        
  +        if not os.path.exists(self.logdir): os.makedirs(self.logdir)
  +    
  +        # Construct repository dir on demand
  +        if not self.xml.jardir: 
  +            self.jardir=os.path.join(self.getBaseDirectory(),"repo")
  +        else:
  +            self.jardir=self.xml.jardir
  +                
  +        if not os.path.exists(self.jardir): os.makedirs(self.jardir)
  +    
  +        # Construct CVS directory on demand
  +        if not self.xml.cvsdir: 
  +            self.cvsdir=os.path.join(self.getBaseDirectory(),"cvs")
  +        else:
  +            self.cvsdir=self.xml.cvsdir
  +
  +        if not os.path.exists(self.cvsdir): os.makedirs(self.cvsdir)
  +    
  +        # Package Dir Ought Exist
  +        if not self.xml.pkgdir: 
  +            self.pkgdir=self.getBaseDirectory()
  +        else:
  +            self.pkgdir=self.xml.pkgdir
  +        
  +        if self.xml.deliver:
  +            if not self.xml.scratchdir: 
  +                self.scratchdir=os.path.join(self.getBaseDirectory(),"scratch")
  +            else:
  +                self.scratchdir=self.xml.scratchdir
  +        
  +   
  +    def setDatedDirectories(self,date=None):
  +        
  +        # This build date
  +        if not date: date = gump.default.date
  +            
  +        # Construct tmp on demand
  +        self.tmpdir=os.path.join(self.tmpdir,date)            
  +        if not os.path.exists(self.tmpdir): 
  +            os.makedirs(self.tmpdir)    
  +    
  +        # Construct logdir on demand
  +        self.logdir=os.path.join(self.logdir,date)
  +        if not os.path.exists(self.logdir): os.makedirs(self.logdir)
   
               
       def addModule(self,module):
  
  
  
  1.5       +42 -20    jakarta-gump/python/gump/syndication/rss.py
  
  Index: rss.py
  ===================================================================
  RCS file: /home/cvs/jakarta-gump/python/gump/syndication/rss.py,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- rss.py	6 Dec 2003 01:42:29 -0000	1.4
  +++ rss.py	6 Dec 2003 18:01:48 -0000	1.5
  @@ -122,15 +122,24 @@
           self.url=url
           self.image=image
           
  -    def serialize(self,rssStream):
  -        self.rssStream = rssStream       
  +    def serialize(self,rssStream,rssUrl):
  +        self.rssStream = rssStream    
  +        self.rssUrl=rssUrl   
           
           self.rssStream.write('   <item>\n')
           
  +        # Tag on description
  +        tagOn=("""
  +        <a href="http://feedvalidator.org/check?url=%s">
  +            <img align="right" src="http://feedvalidator.org/images/valid-rss.png" 
  +                alt="[Valid RSS]" title="Validate my RSS feed" width="88" height="31" />
  +        </a>""") % (self.rssUrl)
  +        
           # Mandatory Fields
           self.rssStream.write(('    <title>Gump: %s</title>\n') %(escape(self.title)))
           self.rssStream.write(('    <link>%s</link>\n') %(escape(self.link)))
  -        self.rssStream.write(('    <description>%s</description>\n') %(escape(self.description)))
  +        self.rssStream.write(('    <description>%s%s</description>\n') \
  +                %(escape(self.description),escape(tagOn)))
           self.rssStream.write('    <author>gump@jakarta.apache.org</author>\n')
               
           
           self.rssStream.write(('      <dc:subject>%s</dc:subject>\n') %(escape(self.subject)))
  @@ -178,7 +187,6 @@
           self.rssStream.write("""
       <gump:version>%s</gump:version>
       
  -    <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>
  @@ -188,14 +196,15 @@
       def endChannel(self):
           self.rssStream.write('  </channel>\n')
           
  -    def serialize(self,rssStream):
  +    def serialize(self,rssStream,rssUrl):
           self.rssStream = rssStream
  +        self.rssUrl=rssUrl
           
           self.startChannel()
           
           # Serialize all items
           for item in self.items:
  -            item.serialize(self.rssStream)
  +            item.serialize(self.rssStream,self.rssUrl)
               
           self.endChannel()
           
  @@ -203,7 +212,8 @@
           self.items.append(item)
       
   class RSS:
  -    def __init__(self,file,channel=None):
  +    def __init__(self,url,file,channel=None):
  +        self.rssUrl=url
           self.rssFile=file
           
           self.channels=[]
  @@ -231,7 +241,7 @@
           self.startRSS()
           
           for channel in self.channels:
  -            channel.serialize(self.rssStream)
  +            channel.serialize(self.rssStream,self.rssUrl)
           
           self.endRSS()
           
  @@ -260,10 +270,10 @@
           # Main syndication document
           self.run = run
           self.workspace=run.getWorkspace()   
  -        self.rssFile=os.path.abspath(os.path.join(	\
  -                    self.workspace.logdir,'index.rss'))
  +        self.rssFile=self.run.getOptions().getResolver().getFile(self.workspace,'index','.rss')
     
  +        self.rssUrl=self.run.getOptions().getResolver().getUrl(self.workspace,'index','.rss')
       
  -        self.rss=RSS(self.rssFile,	\
  +        self.rss=RSS(self.rssUrl,self.rssFile,	\
               Channel('Jakarta Gump',		\
                       self.workspace.logurl,	\
                       """Life is like a box of chocolates""", \
  @@ -278,11 +288,12 @@
       def syndicateModule(self,module,mainRSS):
           
           rssFile=self.run.getOptions().getResolver().getFile(module,'index','.rss')
  -        moduleURL=self.run.getOptions().getResolver().getUrl(module)
  +        rssUrl=self.run.getOptions().getResolver().getUrl(module,'index','.rss')
  +        moduleUrl=self.run.getOptions().getResolver().getUrl(module)
           
  -        moduleRSS=RSS(rssFile,	\
  +        moduleRSS=RSS(rssUrl,rssFile,	\
               Channel('Gump : Module ' + escape(module.getName()),	\
  -                    moduleURL,	\
  +                    moduleUrl,	\
                       escape(module.getDescription()), \
                       self.gumpImage))
                         
  @@ -299,7 +310,7 @@
           #
           #
           item=Item(('%s %s %s') % (module.getName(),module.getStateDescription(),datestr),
\
  -                  moduleURL, \
  +                  moduleUrl, \
                     content, \
                     module.getName(), \
                     ('%sT%s%s') % (datestr,timestr,TZ))
  @@ -309,6 +320,15 @@
               not s.currentState == STATE_UNSET:   
               moduleRSS.addItem(item)  
               
  +        # State changes that are newsworthy...
  +        if 	s.sequenceInState == 1	\
  +            and not s.currentState == STATE_PREREQ_FAILED \
  +            and not s.currentState == STATE_UNSET \
  +            and not s.currentState == STATE_NONE \
  +            and not s.currentState == STATE_COMPLETE  \
  +            and not module.isPackaged() :       
  +            mainRSS.addItem(item)
  +            
           for project in module.getProjects():  
               self.syndicateProject(project,moduleRSS,mainRSS)      
                     
  @@ -317,11 +337,12 @@
       def syndicateProject(self,project,moduleRSS,mainRSS):
                   
           rssFile=self.run.getOptions().getResolver().getFile(project,project.getName(),'.rss')
  -        projectURL=self.run.getOptions().getResolver().getUrl(project)
  +        rssUrl=self.run.getOptions().getResolver().getUrl(project,'index','.rss')
  +        projectUrl=self.run.getOptions().getResolver().getUrl(project)
           
  -        projectRSS=RSS(rssFile,	\
  +        projectRSS=RSS(rssUrl, rssFile,	\
               Channel('Gump : Project ' + escape(project.getName()),	\
  -                    projectURL,	\
  +                    projectUrl,	\
                       escape(project.getDescription()), \
                       self.gumpImage))
                       
  @@ -338,7 +359,7 @@
           #
           #
           item=Item(('%s %s %s') % (project.getName(),project.getStateDescription(),datestr),
\
  -                  projectURL, \
  +                  projectUrl, \
                     content, \
                     project.getModule().getName() + ":" + project.getName(), \
                     ('%sT%s%s') % (datestr,timestr,TZ))
  @@ -354,7 +375,8 @@
               and not s.currentState == STATE_PREREQ_FAILED \
               and not s.currentState == STATE_UNSET \
               and not s.currentState == STATE_NONE \
  -            and not s.currentState == STATE_COMPLETE :       
  +            and not s.currentState == STATE_COMPLETE 	\
  +            and not project.isPackaged() :       
               mainRSS.addItem(item)
                                                           
           projectRSS.serialize()
  
  
  
  1.4       +33 -26    jakarta-gump/python/gump/syndication/syndicator.py
  
  Index: syndicator.py
  ===================================================================
  RCS file: /home/cvs/jakarta-gump/python/gump/syndication/syndicator.py,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- syndicator.py	6 Dec 2003 01:42:29 -0000	1.3
  +++ syndicator.py	6 Dec 2003 18:01:48 -0000	1.4
  @@ -97,15 +97,9 @@
           
           stats=project.getStats()
           
  -        content='Project ' + project.getName() \
  -                                + ' : ' \
  -                                + project.getStateDescription()
  -                            
  -        if not project.getStatePair().isReasonUnset():
  -           content += ' with reason ' \
  -                + project.getReasonDescription()
  -            
  -        content += '\n\n'
  +        content='Project ' + project.getName() 
  +                                
  +        content += self.getStateContent(project.getStatePair())
                           
           if not stats.previousState == STATE_NONE \
               and not stats.previousState == STATE_UNSET:
  @@ -113,7 +107,7 @@
                                       + stateName(stats.previousState)  \
                                       + '\n\n'
       
  -        content += self.addSundries(project)
  +        content += self.getSundries(project)
                   
           return content
   
  @@ -125,15 +119,9 @@
           
           stats=module.getStats()
           
  -        content='Module ' + module.getName() \
  -                                + ' : ' \
  -                                + module.getStateDescription()	
  -                            
  -        if not module.getStatePair().isReasonUnset():
  -           content += ' with reason ' \
  -                + module.getReasonDescription()
  -            
  -        content += '\n\n'
  +        content='Module ' + module.getName()
  +                                    
  +        content += self.getStateContent(module.getStatePair())
                           
           if not stats.previousState == STATE_NONE \
               and not stats.previousState == STATE_UNSET:
  @@ -141,26 +129,43 @@
                                       + stateName(stats.previousState)  \
                                       + '\n\n'
       
  -        content += self.addSundries(module)
  +        content += self.getSundries(module)
                   
           return content
   
  -    def addSundries(self,object):
  +    def getStateContent(self,statePair):
  +        
  +        resolver=self.run.getOptions().getResolver()    
  +        
  +        content = 'Gump State: ' + statePair.getStateDescription()	
  +                            
  +        if not statePair.isReasonUnset():
  +           content += ' with reason ' \
  +                + statePair.getReasonDescription()
  +        
  +        content += ( '&nbsp;<img href=\'%s\' alt=\'%s\'/>' ) % \
  +            resolver.getStateIconInformation(statePair)
  +            
  +        content += '<br><br>'
  +        
  +        return content
  +        
  +    def getSundries(self,object):
           
           content = ''
           
           resolver=self.run.getOptions().getResolver()    
           
           if object.annotations:
  -            content += '<table>'
  +            content += '<p><table>'
               for note in object.annotations:
                       content += ('<tr><td>' \
                           + note.getLevelName() + '</td><td>' \
                           + note.getText() + '</td></tr>\n')                
  -            content += '<table>'
  +            content += '<table></p>'
               
           if object.worklist:
  -            content += '<table>'    
  +            content += '<p><table>'    
               for work in object.worklist:
                   url=resolver.getAbsoluteUrl(work)
                   state=stateName(work.state)                 
  @@ -168,11 +173,13 @@
                       url + '\'>' + work.getName() + 	\
                       '</a></td><td>' + state + 		\
                       '</td></tr>\n')                   
  -            content += '<table>'
  +            content += '<table></p>'
               
  -        content += '\n\n\n<img alt=\'Brought to you by Jakarta Gump\' src=\'http://jakarta.apache.org/gump/images/bench.png\'/>'
  +        content += '\n\n<hr>\n<img align=\'left\' alt=\'Brought to you by Jakarta
Gump\' src=\'http://jakarta.apache.org/gump/images/bench.png\'/>'
           
           return content
  +
  +        
                 
   def syndicate(run):
       
  
  
  
  1.7       +25 -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.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- resolver.py	2 Dec 2003 22:36:46 -0000	1.6
  +++ resolver.py	6 Dec 2003 18:01:48 -0000	1.7
  @@ -68,6 +68,7 @@
   import sys
   import logging
   from xml.sax.saxutils import escape
  +from string import lower,replace
   
   from gump import log
   from gump.config import *
  @@ -81,6 +82,7 @@
   from gump.model.project import Project
   from gump.model.ant import Ant
   from gump.model.object import *
  +from gump.model.state import *
   
   class Path(list):
       
  @@ -383,4 +385,26 @@
           
       def getUrl(self,object,documentName=None,extn='.html'):
           return self.getAbsoluteUrl(object,documentName,extn)
  -        
  \ No newline at end of file
  +        
  +        
  +    def getRootUrl(self):
  +        return self.rootUrl
  +        
  +    def getAbsoluteUrlForRelative(self,relativeToRoot):
  +        return concatenate(self.rootUrl,relativeToRoot)
  +        
  +    def getStateIconInformation(self,statePair):
  +        
  +        # :TODO: Move this to some resolver, and share with RSS
  +        sname=statePair.getStateDescription()  
  +        rdesc=statePair.getReasonDescription()
  +            
  +        description=sname    
  +        if rdesc: 
  +            description+=' with reason '+rdesc
  +        
  +        # Build the URL to the icon
  +        iconName=gumpSafeName(lower(replace(sname,' ','_')))
  +        url = self.getAbsoluteUrlForRelative("gump_icons/"+iconName+".png")
  +        
  +        return (url, description)
  \ No newline at end of file
  
  
  
  1.31      +2 -0      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.30
  retrieving revision 1.31
  diff -u -r1.30 -r1.31
  --- forrest.py	5 Dec 2003 15:13:21 -0000	1.30
  +++ forrest.py	6 Dec 2003 18:01:48 -0000	1.31
  @@ -1339,6 +1339,8 @@
       def insertStatePairIcon(self,xdocNode,toObject,fromObject):
           pair=toObject.getStatePair()
           depth=getDepthForObject(fromObject)
  +        
  +        # :TODO: Move this to some resolver, and share with RSS
           sname=stateName(pair.state)
           rstring=reasonString(pair.reason)    
   
  
  
  

Mime
View raw message