gump-general mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From aj...@apache.org
Subject cvs commit: gump/python/gump/utils domutils.py work.py
Date Mon, 28 Jun 2004 21:17:00 GMT
ajack       2004/06/28 14:17:00

  Modified:    python/gump Tag: CleanUp preview.py
               python/gump/document/xdocs Tag: CleanUp documenter.py
               python/gump/loader Tag: CleanUp loader.py
               python/gump/model Tag: CleanUp module.py object.py
                        project.py workspace.py
               python/gump/notify Tag: CleanUp notification.py notifier.py
               python/gump/utils Tag: CleanUp domutils.py work.py
  Log:
  Trying to splice (need to clone, despite it being a memory hog).
  
  Revision  Changes    Path
  No                   revision
  No                   revision
  1.5.2.2   +7 -3      gump/python/gump/preview.py
  
  Index: preview.py
  ===================================================================
  RCS file: /home/cvs/gump/python/gump/preview.py,v
  retrieving revision 1.5.2.1
  retrieving revision 1.5.2.2
  diff -u -r1.5.2.1 -r1.5.2.2
  --- preview.py	11 Jun 2004 20:46:10 -0000	1.5.2.1
  +++ preview.py	28 Jun 2004 21:16:59 -0000	1.5.2.2
  @@ -81,18 +81,22 @@
           for module in run.getGumpSet().getModules():
               print SEPARATOR
               print `module`
  +            if debug:
  +                print module.getXml()
               module.dump()
               if module.isUpdatable():
                   updater.preview(module)
                          
  -        
           for project in run.getGumpSet().getProjects():
               print SEPARATOR
               print `project`
  +            if debug:
  +                print project.getXml()
  +            project.dump()
               if project.hasBuildCommand():
                   builder.preview(project)
       
  -    # Show nasties...
  +    # Show any nasties...
       if workspace.containsNasties():
           print SEPARATOR    
           print `workspace`    
  
  
  
  No                   revision
  No                   revision
  1.9.2.25  +15 -9     gump/python/gump/document/xdocs/documenter.py
  
  Index: documenter.py
  ===================================================================
  RCS file: /home/cvs/gump/python/gump/document/xdocs/documenter.py,v
  retrieving revision 1.9.2.24
  retrieving revision 1.9.2.25
  diff -u -r1.9.2.24 -r1.9.2.25
  --- documenter.py	27 Jun 2004 22:50:41 -0000	1.9.2.24
  +++ documenter.py	28 Jun 2004 21:16:59 -0000	1.9.2.25
  @@ -1598,7 +1598,7 @@
       #    footerXDoc(x)
       #    endXDoc(x)
           
  -    def documentProject(self,project,realTime=0): 
  +    def documentProject(self,project,realTime=False): 
           
           spec=self.resolver.getFileSpec(project)
           document=XDocDocument('Project : ' + project.getName(),    
  @@ -1664,6 +1664,9 @@
           self.insertLink(project.getModule(),project,	\
                   detailsList.createEntry('Containing Module: '))        
           
  +        if project.isSpliced():
  +            detailsList.createEntry('XML Spliced: ', `project.isSpliced()`)
  +            
           if project.hasHomeDirectory() and project.isVerboseOrDebug():
               detailsList.createEntry('Home Directory: ', project.getHomeDirectory())
               
  @@ -1712,7 +1715,7 @@
           
           statsTable=statsSection.createTable()           
           
  -        if self.config.isXdocs():
  +        if (not realTime) and self.config.isXdocs():
               # Generate an SVG for FOG:
               (file,title) = self.diagramFOG(project)
               if file:
  @@ -1736,14 +1739,16 @@
                   
           self.documentFileList(document,project,'Project-level Files')  
                   
  -        addnSection=document.createSection('Additional Details')
  -        addnPara=addnSection.createParagraph()
  -        addnPara.createLink('details.html',	
  -                              'For additional project details (including classpaths,dependencies)
...')
  +        if not realTime:
  +            addnSection=document.createSection('Additional Details')
  +            addnPara=addnSection.createParagraph()
  +            addnPara.createLink('details.html',	
  +                                  'For additional project details (including classpaths,dependencies)
...')
                                   
           document.serialize()
           
  -        self.documentProjectDetails(project,realTime)
  +        if not realTime:
  +            self.documentProjectDetails(project,realTime)
           
       def documentProjectDetails(self,project,realTime=0):         
           
  @@ -2131,11 +2136,12 @@
               stream.write('Failed to XML serialize the data. ' + str(details))
           stream.seek(0)
           xmldata=stream.read()
  -        if len(xmldata) < 32000:
  +        if (not self.config.isXdocs()) or (len(xmldata) < 32000):
               xmlSection.createSource(xmldata)
           else:
  -            xmlSection.createParagraph('XML Data too large to display.')
  +            xmlSection.createParagraph('XML Data too large to display via Forrest.')
           stream.close()
  +        stream=None
               
       def documentSummary(self,xdocNode,summary,description='Project Summary'):
           if not summary or not summary.projects \
  
  
  
  No                   revision
  No                   revision
  1.1.2.9   +8 -3      gump/python/gump/loader/Attic/loader.py
  
  Index: loader.py
  ===================================================================
  RCS file: /home/cvs/gump/python/gump/loader/Attic/loader.py,v
  retrieving revision 1.1.2.8
  retrieving revision 1.1.2.9
  diff -u -r1.1.2.8 -r1.1.2.9
  --- loader.py	24 Jun 2004 20:15:56 -0000	1.1.2.8
  +++ loader.py	28 Jun 2004 21:17:00 -0000	1.1.2.9
  @@ -214,7 +214,7 @@
               if not task.isFailed():
                   dom=task.getResult().getDom()
                   
  -                # What are we workign with
  +                # What are we working with for this document
                   element=dom.documentElement
                   name=None
                   if element.hasAttribute('name'):            
  @@ -231,6 +231,9 @@
                   # Allow context instantiation, or we are root
                   if parentObject:
                       object=parentObject.getObjectForTag(element.tagName,dom,name)
  +                    
  +                    log.debug("Used parent: %s to get %s for <%s %s" %(`parentObject`,`object`,
  +                                `element.tagName`,`name`))  
                   else:
                       if name: object=cls(name,dom)
                       else:    object.cls(dom)
  @@ -240,11 +243,13 @@
                       # Store the metadata
                       object.setMetadataLocation(task.getLocation())
                       # Resolve entities...
  -                    object.resolve()                    
  +                    if not object.isResolved():
  +                        object.resolve()                    
                       task.getResult().setObject(object)
               
           if rootObject:
  -            rootObject.resolve()
  +            if not rootObject.isResolved():
  +                rootObject.resolve()
               # Cook the raw model...                    
               rootObject.complete()
                
  
  
  
  No                   revision
  No                   revision
  1.45.2.9  +53 -18    gump/python/gump/model/module.py
  
  Index: module.py
  ===================================================================
  RCS file: /home/cvs/gump/python/gump/model/module.py,v
  retrieving revision 1.45.2.8
  retrieving revision 1.45.2.9
  diff -u -r1.45.2.8 -r1.45.2.9
  --- module.py	25 Jun 2004 23:08:52 -0000	1.45.2.8
  +++ module.py	28 Jun 2004 21:17:00 -0000	1.45.2.9
  @@ -196,8 +196,35 @@
           self.workspace=None
           self.workdir=None
           
  +           
  +    def getObjectForTag(self,tag,dom,name=None):
  +        """
  +        	Get a new (or spliced) object for this tag	
  +        """
  +        
  +        object=None
  +      
  +        if 'project' == tag:
  +            
  +            owner=self.getOwner()
  +            if self.hasProject(name):
  +                object=self.getProject(name)
  +                object.splice(dom)
  +            elif owner.hasProject(name):
  +                object=owner.getProject(name)
  +                object.splice(dom)
  +                self.addProject(object)
  +            else:
  +                from gump.model.project import Project    
  +                object=Project(name,dom,self)
  +                self.addProject(object)
  +
  +        return object                                          
  +      
       def resolve(self):
           
  +        if self.isResolved(): return
  +        
           log.info('Resolve ' + `self`)
           
           owner=self.getOwner()
  @@ -208,10 +235,7 @@
                   
                   if owner.hasProject(name):
                       project=owner.getProject(name)
  -                    
  -                    # Hmm, safe even if duplicate?
  -                    # Ought we detect before?
  -                    project.splice(pdom)                    
  +                            
                       if not self.hasProject(name):
                           if not project.inModule() or (project.getModule() == self):
                               self.addProject(project)
  @@ -219,11 +243,16 @@
                               pass 
                               # Duplicate project... Hmm
                               # :TODO:
  -                            
  +                    project.splice(pdom)
  +                elif self.hasProject(name):                    
  +                    project.splice(pdom)
                   else:
                       project=Project(name,pdom,self)
                       self.addProject(project)
  +                    
           log.info('Resolved ' + `self`)
  +        
  +        self.setResolved()
                   
       # provide default elements when not defined in xml
       def complete(self,workspace):
  @@ -401,11 +430,28 @@
           return self.notifys
           
       def addProject(self,project):
  +        """
  +        	Associate this module with this project, and vice verse.
  +        """
  +        name=project.getName()
  +        
  +        if self.hasProject(name):
  +            raise RuntimeError, 'Attempt to add duplicate project: ' + name
  +            
  +        # Reference this module as owner
           project.setModule(self)
  -        self.projects[project.getName()]=project
           
  -        if not self.getOwner().hasProject(project.getName()):
  +        # Stash project
  +        self.projects[name]=project
  +        
  +        # Teach workspace about this also...
  +        if not self.getOwner().hasProject(name):
               self.getOwner().addProject(project)
  +        else:
  +            otherProject=self.getOwner().getProject(name)
  +            
  +            if not project is otherProject:
  +                raise RuntimeError, 'Attempt to add duplicate project (in module): ' +
name    
                        
       def hasProject(self,name):
           return self.projects.has_key(name)
  @@ -521,17 +567,6 @@
           # self.summary = summary
           
           return summary
  -           
  -    def getObjectForTag(self,tag,dom,name=None):
  -        object=None
  -      
  -        if 'project' == tag:
  -            from gump.model.project import Project
  -            object=Project(name,dom,self)
  -            self.addProject(object)
  -
  -        return object                                          
  -        
       def dump(self, indent=0, output=sys.stdout):
           output.write(getIndent(indent)+'Module : ' + self.name + '\n')
           NamedModelObject.dump(self, indent+1, output)
  
  
  
  1.24.2.9  +33 -4     gump/python/gump/model/object.py
  
  Index: object.py
  ===================================================================
  RCS file: /home/cvs/gump/python/gump/model/object.py,v
  retrieving revision 1.24.2.8
  retrieving revision 1.24.2.9
  diff -u -r1.24.2.8 -r1.24.2.9
  --- object.py	25 Jun 2004 23:08:52 -0000	1.24.2.8
  +++ object.py	28 Jun 2004 21:17:00 -0000	1.24.2.9
  @@ -65,7 +65,8 @@
       	self.verbose=False
       	self.metadata=None
       	
  -    	self.completionPerformed=0
  +        self.resolutionPerformed=False
  +        self.completionPerformed=False
       	
       def __del__(self):
           Annotatable.__del__(self)
  @@ -77,11 +78,34 @@
           # No longer need this...
           self.dom=None
           
  +    def shutdown(self):
  +        """
  +        
  +        	Shut this object down to the bare minimim,
  +        	to conserve memory after it is 'done with'.
  +        	
  +        """
  +        if self.dom:
  +            self.dom.unlink()
  +            if self.element:
  +                if not self.element is self.dom:
  +                    self.element.unlink()
  +                self.element=None
  +            self.dom=None
  +            
  +        self.shutdownWork()
  +        
  +    def isResolved(self):
  +        return self.resolutionPerformed
  +        
  +    def setResolved(self,resolved=True):
  +       self.resolutionPerformed=resolved
  +       
       def isComplete(self):
           return self.completionPerformed
           
  -    def setComplete(self,complete):
  -       self.completionPerformed=complete
  +    def setComplete(self,complete=True):
  +        self.completionPerformed=complete
          
       def setDebug(self,debug):
           self.debug=debug
  @@ -113,6 +137,9 @@
           # output.write(getIndent(indent)+'Class: ' + self.__class__.__name__ + '\n')
           if self.hasOwner():
               output.write(getIndent(indent)+'Owner: ' + `self.getOwner()` + '\n')
  +        output.write(getIndent(indent)+'Id: ' + `id(self)` + '\n')
  +        #output.write(getIndent(indent)+'Id DOM: ' + `id(self.dom)` + '\n')
  +        #output.write(getIndent(indent)+'Id Element: ' + `id(self.element)` + '\n')
           if self.isSpliced():
               output.write(getIndent(indent)+'Was *Spliced*\n')
           Annotatable.dump(self,indent,output)
  @@ -176,7 +203,7 @@
       def writeXmlToFile(self, outputFile):
           try:            
               f=open(outputFile, 'w')
  -            f.write(self.getXmlData())
  +            self.writeXml(f)
           finally:
               # Since we may exit via an exception, close explicitly.
               if f: f.close()    
  @@ -227,6 +254,8 @@
           
       def splice(self,dom): 
           log.info('Splice ' + `self`)
  +        if self.isComplete():
  +            raise RuntimeError, "Can't splice a completed entity: " + `self`
           spliceDom(self.element,dom)
           self.setSpliced(True) 
                               	
  
  
  
  1.85.2.13 +3 -1      gump/python/gump/model/project.py
  
  Index: project.py
  ===================================================================
  RCS file: /home/cvs/gump/python/gump/model/project.py,v
  retrieving revision 1.85.2.12
  retrieving revision 1.85.2.13
  diff -u -r1.85.2.12 -r1.85.2.13
  --- project.py	25 Jun 2004 23:08:52 -0000	1.85.2.12
  +++ project.py	28 Jun 2004 21:17:00 -0000	1.85.2.13
  @@ -15,7 +15,9 @@
   # limitations under the License.
   
   """
  -    This module contains information on Project
  +
  +    The model for a 'Project'
  +    
   """
   
   from time import localtime, strftime, tzname
  
  
  
  1.51.2.9  +13 -9     gump/python/gump/model/workspace.py
  
  Index: workspace.py
  ===================================================================
  RCS file: /home/cvs/gump/python/gump/model/workspace.py,v
  retrieving revision 1.51.2.8
  retrieving revision 1.51.2.9
  diff -u -r1.51.2.8 -r1.51.2.9
  --- workspace.py	25 Jun 2004 23:08:52 -0000	1.51.2.8
  +++ workspace.py	28 Jun 2004 21:17:00 -0000	1.51.2.9
  @@ -185,6 +185,8 @@
           return self.modules.has_key(mname)
           
       def addModule(self,module):
  +        if self.hasModule(name):
  +            raise RuntimeError, 'Attempt to add duplicate module: ' + name    
           self.modules[module.getName()]=module
           
       def getModule(self,mname):
  @@ -203,7 +205,10 @@
           return self.projects.has_key(pname)
           
       def addProject(self,project):
  -        self.projects[project.getName()]=project
  +        name=project.getName()
  +        if self.hasProject(name):
  +            raise RuntimeError, 'Attempt to add duplicate project: ' + name    
  +        self.projects[name]=project
           
       def getProject(self,pname):
           return self.projects[pname]
  @@ -282,24 +287,19 @@
   
           # Complete the modules
           for module in self.getModules():
  -            module.complete(self)
  +            if not module.isComplete():
  +                module.complete(self)
           
  -        #
           # Check repositories, now modules have been imported,
           # so we can report those unused ones.
  -        #
           for repository in self.getRepositories(): 
               repository.check(self)           
           
  -        #
           # Check servers.
  -        #
           for server in self.getServers(): 
               server.check(self)            
           
  -        #
           # Check Trackers.
  -        #
           for tracker in self.getTrackers(): 
               tracker.check(self)           
           
  @@ -509,6 +509,8 @@
           
       def resolve(self):
           
  +        if self.isResolved(): return
  +        
           log.info('Resolve ' + `self`)
           
           for pdom in self.getDomChildIterator('project'):
  @@ -522,7 +524,9 @@
                       project=Project(name,pdom,self)
                       self.addProject(project)   
           
  -        log.info('Resolved ' + `self`)     
  +        log.info('Resolved ' + `self`)   
  +        
  +        self.setResolved()  
   
   class WorkspaceStatistics(Statistics):
       """Statistics Holder"""
  
  
  
  No                   revision
  No                   revision
  1.1.2.4   +5 -5      gump/python/gump/notify/notification.py
  
  Index: notification.py
  ===================================================================
  RCS file: /home/cvs/gump/python/gump/notify/notification.py,v
  retrieving revision 1.1.2.3
  retrieving revision 1.1.2.4
  diff -u -r1.1.2.3 -r1.1.2.4
  --- notification.py	25 Jun 2004 23:08:52 -0000	1.1.2.3
  +++ notification.py	28 Jun 2004 21:17:00 -0000	1.1.2.4
  @@ -71,7 +71,7 @@
           if self.intro: return 1
           return 0
           
  -    def resolveContent(self,resolver,stream=None):
  +    def resolveContent(self,resolver,id=None,stream=None):
           
           # If not passed, create temporary
           if not stream:
  @@ -168,7 +168,7 @@
   
           self.resolveSyndication(resolver, stream)
           
  -        self.resolveFooter(resolver, stream)
  +        self.resolveFooter(resolver, id, stream)
       
           # If passed (or created) a StringIO, return String
           # containing contents.
  @@ -217,18 +217,18 @@
           stream.write('To subscribe to this information via syndicated feeds:')
           stream.write('\n')
               
  -        #
           # Link them back here...
  -        #
           rssurl=resolver.getUrl(self.entity,'rss','.xml')
           atomurl=resolver.getUrl(self.entity,'atom','.xml')
               
           stream.write(' RSS: ' + rssurl + '\n')
           stream.write(' Atom: ' + atomurl + '\n')
           
  -    def resolveFooter(self, resolver, stream):
  +    def resolveFooter(self, resolver, id, stream):
           
           stream.write('\n\n--\n')
  +        if id:
  +            stream.write('Gump E-mail Identifier (within run) #%s.\n' % id )
           stream.write('Produced by Gump %s.\n[Run (%s, %s)]' %	\
                           (	setting.version, 
                               default.datetime, 
  
  
  
  1.5.2.6   +7 -6      gump/python/gump/notify/notifier.py
  
  Index: notifier.py
  ===================================================================
  RCS file: /home/cvs/gump/python/gump/notify/notifier.py,v
  retrieving revision 1.5.2.5
  retrieving revision 1.5.2.6
  diff -u -r1.5.2.5 -r1.5.2.6
  --- notifier.py	18 Jun 2004 14:58:16 -0000	1.5.2.5
  +++ notifier.py	28 Jun 2004 21:17:00 -0000	1.5.2.6
  @@ -58,6 +58,8 @@
           
           self.resolver=self.options.getResolver()
           self.logic=NotificationLogic(self.run)
  +        
  +        self.id=0
                                           
       def processWorkspace(self):
           """
  @@ -208,7 +210,7 @@
       def notifyWorkspace(self,notification):
           """ Notify for the workspace """
           
  -        content=notification.resolveContent(self.resolver)
  +        content=notification.resolveContent(self.resolver, self.id)
           
           subject=self.workspace.prefix+': Gump Workspace ' + self.workspace.getName()
           
  @@ -220,7 +222,7 @@
           """ Notify to a specific module's <notify entry """
           
           # Form the content...
  -        content=notification.resolveContent(self.resolver)
  +        content=notification.resolveContent(self.resolver, self.id)
                   
           # Form the subject
           subject=self.workspace.prefix+	\
  @@ -237,7 +239,7 @@
           #
           # Form the content...
           #
  -        content=notification.resolveContent(self.resolver)
  +        content=notification.resolveContent(self.resolver, self.id)
                   
           # Form the subject
           subject=self.workspace.prefix+': '	\
  @@ -293,10 +295,10 @@
       
           sent=False
           try:
  -               
  -            log.info('Send Notify e-mail:\n To: ' + str(toaddr) + \
  +            log.info('Send Notify e-mail (#' + `self.id` + ') :\n To: ' + str(toaddr) +
\
                   '\n From: ' + str(fromaddr) + \
                   '\n Subject: ' + str(subject))
  +            self.id+=1 
              
               # Form the user visable part ...
               email=EmailMessage( toaddrs, 
  @@ -315,7 +317,6 @@
                           self.workspace.mailserver,	\
                           self.workspace.mailport)  
                      
  -            
           except Exception, details:
               sent=False
               log.error('Failed to send notify e-mail: ' + str(details), \
  
  
  
  No                   revision
  No                   revision
  1.1.2.6   +4 -4      gump/python/gump/utils/Attic/domutils.py
  
  Index: domutils.py
  ===================================================================
  RCS file: /home/cvs/gump/python/gump/utils/Attic/domutils.py,v
  retrieving revision 1.1.2.5
  retrieving revision 1.1.2.6
  diff -u -r1.1.2.5 -r1.1.2.6
  --- domutils.py	25 Jun 2004 23:08:52 -0000	1.1.2.5
  +++ domutils.py	28 Jun 2004 21:17:00 -0000	1.1.2.6
  @@ -204,10 +204,10 @@
       # (i.e. deep clone and copy into target) 
       if sourceElement.hasChildNodes():
           for childNode in sourceElement.childNodes:  
  -            #clonedNode=childNode.cloneNode(True)
  -            #targetElement.appendChild(clonedNode)
  -            targetElement.appendChild(childNode)
  -    
  +            # Cloning seems to seriously abuse memory... :(
  +            clonedNode=childNode.cloneNode(True)
  +            targetElement.appendChild(clonedNode) 
  +            #targetElement.appendChild(childNode) 
       
   #    
   #def getAttrValue(node,attrName):
  
  
  
  1.15.4.6  +7 -0      gump/python/gump/utils/work.py
  
  Index: work.py
  ===================================================================
  RCS file: /home/cvs/gump/python/gump/utils/work.py,v
  retrieving revision 1.15.4.5
  retrieving revision 1.15.4.6
  diff -u -r1.15.4.5 -r1.15.4.6
  --- work.py	23 Jun 2004 21:38:42 -0000	1.15.4.5
  +++ work.py	28 Jun 2004 21:17:00 -0000	1.15.4.6
  @@ -173,6 +173,10 @@
           self.nameIndex=None
           self.timing=None
           
  +    def shutdown(self):
  +        self.nameIndex=None
  +        del self[:]
  +        
       def add(self,item):
           
           if item.hasOwner():
  @@ -259,4 +263,7 @@
                  
       def getElapsedSecs(self):
           return self.worklist.getElapsedSecs()
  +        
  +    def shutdownWork(self):
  +        self.worklist.shutdown()
       
  
  
  

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


Mime
View raw message