You are viewing a plain text version of this content. The canonical link for it is here.
Posted to general@gump.apache.org by aj...@apache.org on 2004/02/28 01:08:49 UTC

cvs commit: jakarta-gump/python/gump/results loader.py model.py resulter.py __init__.py rawmodel.py

ajack       2004/02/27 16:08:49

  Modified:    python/gump engine.py
               python/gump/document resolver.py
               python/gump/output nag.py
               python/gump/results loader.py model.py resulter.py
                        __init__.py
  Added:       python/storage/results resulter.py __init__.py model.py
                        .cvsignore loader.py
  Removed:     python/gump/results rawmodel.py
  Log:
  Generate (and read from another server) results.xml
  
  Revision  Changes    Path
  1.1                  jakarta-gump/python/storage/results/resulter.py
  
  Index: resulter.py
  ===================================================================
  #!/usr/bin/env python
  
  # $Header: /home/cvs/jakarta-gump/python/gump/output/nag.py,v 1.12 2004/02/15 17:32:05 ajack Exp $
  # $Revision: 1.12 $
  # $Date: 2004/02/15 17:32:05 $
  #
  # ====================================================================
  #
  # The Apache Software License, Version 1.1
  #
  # Copyright (c) 2003 The Apache Software Foundation.  All rights
  # reserved.
  #
  # Redistribution and use in source and binary forms, with or without
  # modification, are permitted provided that the following conditions
  # are met:
  #
  # 1. Redistributions of source code must retain the above copyright
  #    notice, this list of conditions and the following disclaimer.
  #
  # 2. Redistributions in binary form must reproduce the above copyright
  #    notice, this list of conditions and the following disclaimer in
  #    the documentation and/or other materials provided with the
  #    distribution.
  #
  # 3. The end-user documentation included with the redistribution, if
  #    any, must include the following acknowlegement:
  #       "This product includes software developed by the
  #        Apache Software Foundation (http://www.apache.org/)."
  #    Alternately, this acknowlegement may appear in the software itself,
  #    if and wherever such third-party acknowlegements normally appear.
  #
  # 4. The names "The Jakarta Project", "Alexandria", and "Apache Software
  #    Foundation" must not be used to endorse or promote products derived
  #    from this software without prior written permission. For written
  #    permission, please contact apache@apache.org.
  #
  # 5. Products derived from this software may not be called "Apache"
  #    nor may "Apache" appear in their names without prior written
  #    permission of the Apache Group.
  #
  # THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
  # WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
  # OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  # DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
  # ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
  # USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  # ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
  # OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
  # OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  # SUCH DAMAGE.
  # ====================================================================
  #
  # This software consists of voluntary contributions made by many
  # individuals on behalf of the Apache Software Foundation.  For more
  # information on the Apache Software Foundation, please see
  # <http://www.apache.org/>.
  
  """
      Results (XML document containing states/dates/etc.)
  """
  
  import socket
  import time
  import os
  import sys
  import logging
  
  from string import lower, capitalize
  
  from gump import log
  from gump.results.model import *
  from gump.results.loader import *
  
  class Resulter:
      
      def __init__(self,run):        
          self.run = run
          self.workspace=run.getWorkspace()
          self.gumpSet=run.getGumpSet()
          
          self.serverResults = {}
          
      #def getResultsFor(self, object):
      #    for server in self.workspace.getServers():
              
          
      def loadResultsForServers(self):
          for server in self.workspace.getServers():       
              if not server in self.serverResults:
                  results=None
                  try:
                      results=loadResultsForServer(server)            
                  except:
                      pass
                  if results:
                      self.serverResults(server, results)
              
      def loadResultsForServer(self, server):
          return loadResults(server.getUrl() + '/results.xml')
          
      def loadResults(self, url):
      
          loader =  WorkspaceResultLoader()        
          return loader.loadFromUrl(url)
          
      def generateResults(self,where=None):
          """
          Generate a results file
          """
          
          workspaceResults = self.constructResults()
          
          # If not told where to stick it, contstruct...
          if not where: where=workspaceResults.getName()+'.xml'
          
          workspaceResults.writeXMLToFile(where)
          
      def constructResults(self):
          """
          Generate a results file
          """
          # Create
          workspaceResults = WorkspaceResult(self.workspace.getName())
      
          # For all modules...
          for module in self.workspace.getModules():        
                  if not self.gumpSet.inModules(module): continue
                  
                  #
                  # Generate results for this module, and
                  # add all projects.
                  #
                  moduleResults = ModuleResult(module.getName())
  
                  # Set attributes:
                  # Stats?
                  moduleResults.setStatePair(module.getStatePair())
                  
                  # Add projects
                  for project in module.getProjects():
                      if not self.gumpSet.inSequence(project): continue    
                      
                      #
                      # Add a project
                      #
                      projectResults = ProjectResult(project.getName())
                      
                      # Set attributes:
                      projectResults.setStatePair(project.getStatePair())
                  
                      # Stash on moduleResult
                      moduleResults.setProjectResult(projectResults)
                      
                      # Stash on workspaceResult also
                      workspaceResults.setProjectResult(projectResults)                    
                      
                  # Stash moduleResult on workspaceResult
                  workspaceResults.setModuleResult(moduleResults)
                  
          return workspaceResults
              
      
  def generateResults(run):
      
      # Generate results around this run...
      resulter=Resulter(run)
      
      # Generate the output...
      resulter.generateResults()
      
  
  
  1.1                  jakarta-gump/python/storage/results/__init__.py
  
  Index: __init__.py
  ===================================================================
  #!/usr/bin/env python
  
  # $Header: /home/cvspublic/jakarta-gump/python/gump/conf.py,v 1.7 2003/05/10 18:20:36 nicolaken Exp $
  # $Revision: 1.7 $
  # $Date: 2003/05/10 18:20:36 $
  #
  # ====================================================================
  #
  # The Apache Software License, Version 1.1
  #
  # Copyright (c) 2003 The Apache Software Foundation.  All rights
  # reserved.
  #
  # Redistribution and use in source and binary forms, with or without
  # modification, are permitted provided that the following conditions
  # are met:
  #
  # 1. Redistributions of source code must retain the above copyright
  #    notice, this list of conditions and the following disclaimer.
  #
  # 2. Redistributions in binary form must reproduce the above copyright
  #    notice, this list of conditions and the following disclaimer in
  #    the documentation and/or other materials provided with the
  #    distribution.
  #
  # 3. The end-user documentation included with the redistribution, if
  #    any, must include the following acknowlegement:
  #       "This product includes software developed by the
  #        Apache Software Foundation (http://www.apache.org/)."
  #    Alternately, this acknowlegement may appear in the software itself,
  #    if and wherever such third-party acknowlegements normally appear.
  #
  # 4. The names "The Jakarta Project", "Alexandria", and "Apache Software
  #    Foundation" must not be used to endorse or promote products derived
  #    from this software without prior written permission. For written
  #    permission, please contact apache@apache.org.
  #
  # 5. Products derived from this software may not be called "Apache"
  #    nor may "Apache" appear in their names without prior written
  #    permission of the Apache Group.
  #
  # THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
  # WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
  # OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  # DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
  # ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
  # USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  # ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
  # OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
  # OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  # SUCH DAMAGE.
  # ====================================================================
  #
  # This software consists of voluntary contributions made by many
  # individuals on behalf of the Apache Software Foundation.  For more
  # information on the Apache Software Foundation, please see
  # <http://www.apache.org/>.
  
  
  # tell Python what modules make up the gump.output package
  __all__ = ["resulter","module","loader"]
  
  
  
  1.1                  jakarta-gump/python/storage/results/model.py
  
  Index: model.py
  ===================================================================
  #!/usr/bin/env python
  
  # $Header: /home/cvs/jakarta-gump/python/gump/model/object.py,v 1.16 2004/02/10 22:48:52 ajack Exp $
  # $Revision: 1.16 $
  # $Date: 2004/02/10 22:48:52 $
  #
  # ====================================================================
  #
  # The Apache Software License, Version 1.1
  #
  # Copyright (c) 2003 The Apache Software Foundation.  All rights
  # reserved.
  #
  # Redistribution and use in source and binary forms, with or without
  # modification, are permitted provided that the following conditions
  # are met:
  #
  # 1. Redistributions of source code must retain the above copyright
  #    notice, this list of conditions and the following disclaimer.
  #
  # 2. Redistributions in binary form must reproduce the above copyright
  #    notice, this list of conditions and the following disclaimer in
  #    the documentation and/or other materials provided with the
  #    distribution.
  #
  # 3. The end-user documentation included with the redistribution, if
  #    any, must include the following acknowlegement:
  #       "This product includes software developed by the
  #        Apache Software Foundation (http://www.apache.org/)."
  #    Alternately, this acknowlegement may appear in the software itself,
  #    if and wherever such third-party acknowlegements normally appear.
  #
  # 4. The names "The Jakarta Project", "Alexandria", and "Apache Software
  #    Foundation" must not be used to endorse or promote products derived
  #    from this software without prior written permission. For written
  #    permission, please contact apache@apache.org.
  #
  # 5. Products derived from this software may not be called "Apache"
  #    nor may "Apache" appear in their names without prior written
  #    permission of the Apache Group.
  #
  # THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
  # WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
  # OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  # DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
  # ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
  # USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  # ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
  # OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
  # OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  # SUCH DAMAGE.
  # ====================================================================
  #
  # This software consists of voluntary contributions made by many
  # individuals on behalf of the Apache Software Foundation.  For more
  # information on the Apache Software Foundation, please see
  # <http://www.apache.org/>.
  
  """
      This module contains information on
  """
  
  from time import localtime, strftime, tzname
  from string import lower, capitalize
  import xml.dom.minidom
  
  from gump.utils.note import *
  from gump.utils.work import *
  from gump.utils.owner import *
  from gump.model.state import *
  
  
  class ResultModelObject(Annotatable,Ownable,Stateful):
      """Base model object for a single entity"""
      def __init__(self,name,owner=None):
                  
          # Can scribble on this thing...
      	Annotatable.__init__(self)
  
          # Can be owned
          Ownable.__init__(self,owner)
  
          # Holds a state
          Stateful.__init__(self)
      	
      	# Named
      	self.name=name
   
          # Internals...
      	self.completionPerformed=0
      	
      def isComplete(self):
          return self.completionPerformed
          
      def setComplete(self,complete):
         self.completionPerformed=complete
           
      #
      # Same if same type, and same name
      # i.e project context X is not equals to module context X
      def __eq__(self,other):
          return self.__class__ == other.__class__ and self.name == other.name
          
      def __cmp__(self,other):
          return cmp(self.name,other.name)
          
      def __hash__(self):
          return hash(self.name)
          
      def __repr__(self):
          return str(self.__class__)+':'+self.name
          
      def __str__(self):
          return str(self.__class__)+':'+self.name
  
      def getName(self):
          return self.name
          
      def dump(self, indent=0, output=sys.stdout):
          """ Display the contents of this object """
          output.write(getIndent(indent)+'Name: ' + self.name + '\n')
          Annotatable.dump(self,indent,output)
          
      def getDomData(self):
          if not self.hasDomData():
              stream=StringIO.StringIO() 
              
              # Create on demand (push object attributes
              # into Dom form)
              if not self.hasDom():
                  self.createDom()
                  
              xmlize(self.xml.getTagName(),self.xml,stream)
              stream.seek(0)
              self.xmldata=stream.read()
              stream.close()
      
          return self.xmldata
          
      def writeDomToFile(self, outputFile):
          """ Serialize to a file """
          try:            
              f=open(outputFile, 'w')
              f.write(self.getDomData())
          finally:
              # Since we may exit via an exception, close explicitly.
              if f: f.close()            
  
  # represents a <workspaceResult/> element
  class WorkspaceResult(ResultModelObject):
      def __init__(self,name,dom=None,owner=None):
      	ResultModelObject.__init__(self,name,dom,owner)    
      	
      	#
      	# Results per module
      	#
      	self.moduleResults 	=	{}
  
      def hasModuleResults(self):
          if self.moduleResults.values(): return 1
          return 0
          
      def getModuleResults(self):
          return self.moduleResults.values()
          
      def setModuleResult(self,moduleResult):
          self.moduleResults[moduleResult.getName()] = moduleResult
          
      def createDOM(self):
          if self.hasDom(): return
          
      
              
          for moduleResult in self.moduleResults.values():
              moduleResult.createDom(self.xml)        
                      
      def complete(self, dom): 
          if self.isComplete(): return
          
          #
          # Import all modules
          #  
          for xmlmoduleresult in xmlmoduleresults.values(): 
              moduleResult=ModuleResult(xmlmoduleresult.name,xmlmoduleresult,self)
              self.setModuleResult(moduleResult)
                  
          #
          # Import all projects
          #  
          for xmlprojectresult in xmlprojectresults.values():             
              projectResult=ProjectResult(xmlprojectresult.name,xmlprojectresult,self)
              self.setProjectResult(projectResult)
  
          # Complete the modules
          for moduleResult in self.getModuleResults():
              moduleResult.complete(self)
                          
          # Complete the projects  
          for projectResult in self.getProjectResults():
              # Complete the project
              projectResult.complete(self)           
          
          self.setComplete(1)
          
      def dump(self, indent=0, output=sys.stdout):
          """ Display the contents of this object """
          ResultModelObject.dump(self,indent,output)
          
          for moduleResult in self.moduleResults.values():
              moduleResult.dump(indent+1, output)
          
  # represents a <moduleResult/> element
  class ModuleResult(ResultModelObject):
      def __init__(self,name,xml=None,owner=None):
      	ResultModelObject.__init__(self,name,xml,owner)    
      	
      	# 
      	# Results per project
      	#
      	self.projectResults 	=	{}    
      	
      def setProjectResult(self,projectResult):
          self.projectResults[projectResult.getName()] = projectResult
          # Attach oneself as owner...
          projectResult.setModuleResult(self)
                  
      def hasProjectResults(self):
          if self.projectResults.values(): return 1
          return 0    
          
      def getProjectResults(self):
          return self.projectResults.values()
          
      def createDom(self, workspaceResultDom):
          if self.hasDom(): return
          
          # This call constructs a new one...
          self.xml=workspaceResultDom.moduleResult(	\
              {	\
                  'name':self.getName(),	\
                  'state':self.getStateName(),	\
                  'reason':self.getReasonName()	\
              })
              
          for projectResult in self.getProjectResults():
              print "CREATE Dom FOR :" + `projectResult`
              projectResult.createDom(self.xml)
              
      def complete(self, workspaceResult): 
          if self.isComplete(): return
          
          for xmlprojectresult in self.xml.projectResult:
              if workspaceResult.hasProjectResult(xmlprojectresult.name):
                  
                  #
                  # The project pretty much better be in the
                  # workspace, but avoid crashing...
                  #
                  projectResult=workspaceResult.getProjectResult(xmlprojectresult.name)
                  
                  #
                  # Claim ownership
                  #
                  self.setProjectResult(projectResult)
                  
          self.setComplete(1)
          
      def dump(self, indent=0, output=sys.stdout):
          """ Display the contents of this object """
          ResultModelObject.dump(self,indent,output)
          
          for projectResult in self.projectResults.values():
              projectResult.dump(indent+1, output)
              
  # represents a <projectResult/> element
  class ProjectResult(ResultModelObject):
      def __init__(self,name,xml=None,owner=None):
      	ResultModelObject.__init__(self,name,xml,owner)
      	
      	self.moduleResult = None
  
      def createDom(self, moduleResultDom):
          if self.hasDom(): return
          
          self.xml=moduleResultDom.projectResult(	\
              {	\
                  'name':self.getName(),	\
                  'state':self.getStateName(),	\
                  'reason':self.getReasonName()	\
              })
                  
      def setModuleResult(self,moduleResult):
          self.moduleResult=moduleResult
          
      def complete(self,workspaceResult): 
          if self.isComplete(): return
          
          self.setComplete(1)
          
  
  
  
  1.1                  jakarta-gump/python/storage/results/.cvsignore
  
  Index: .cvsignore
  ===================================================================
  *.pyc
  
  
  1.1                  jakarta-gump/python/storage/results/loader.py
  
  Index: loader.py
  ===================================================================
  #!/usr/bin/env python
  
  # $Header: /home/cvs/jakarta-gump/python/gump/model/loader.py,v 1.5 2004/02/01 18:44:44 ajack Exp $
  # $Revision: 1.5 $
  # $Date: 2004/02/01 18:44:44 $
  #
  # ====================================================================
  #
  # The Apache Software License, Version 1.1
  #
  # Copyright (c) 2003 The Apache Software Foundation.  All rights
  # reserved.
  #
  # Redistribution and use in source and binary forms, with or without
  # modification, are permitted provided that the following conditions
  # are met:
  #
  # 1. Redistributions of source code must retain the above copyright
  #    notice, this list of conditions and the following disclaimer.
  #
  # 2. Redistributions in binary form must reproduce the above copyright
  #    notice, this list of conditions and the following disclaimer in
  #    the documentation and/or other materials provided with the
  #    distribution.
  #
  # 3. The end-user documentation included with the redistribution, if
  #    any, must include the following acknowlegement:
  #       "This product includes software developed by the
  #        Apache Software Foundation (http://www.apache.org/)."
  #    Alternately, this acknowlegement may appear in the software itself,
  #    if and wherever such third-party acknowlegements normally appear.
  #
  # 4. The names "The Jakarta Project", "Alexandria", and "Apache Software
  #    Foundation" must not be used to endorse or promote products derived
  #    from this software without prior written permission. For written
  #    permission, please contact apache@apache.org.
  #
  # 5. Products derived from this software may not be called "Apache"
  #    nor may "Apache" appear in their names without prior written
  #    permission of the Apache Group.
  #
  # THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
  # WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
  # OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  # DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
  # ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
  # USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  # ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
  # OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
  # OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  # SUCH DAMAGE.
  # ====================================================================
  #
  # This software consists of voluntary contributions made by many
  # individuals on behalf of the Apache Software Foundation.  For more
  # information on the Apache Software Foundation, please see
  # <http://www.apache.org/>.
  
  """
      This module contains information on
  """
  import os, os.path
  import xml.dom.minidom
  
  from gump import log
  from gump.results.model import WorkspaceResult
  from gump.utils.xmlutils import SAXDispatcher
  from gump.utils.note import transferAnnotations, Annotatable
  from gump.utils import dump
  from gump.config import gumpPath
  
  class WorkspaceResultLoader:
      def __init__(self):
          self.annotations=[]
          
      def loadFromUrl(self,url):
          """Builds in memory from the xml file. Return the generated objects."""
        
          # Download (relative to base)
          if not url.startswith('http://'):
              newurl=gumpPath(url,'.');
          else:
              newurl=cacheHTTP(url)
              
          return self.load(newurl)
          
      def load(self,file):
          """Builds in memory from the xml file. Return the generated objects."""
  
          if not os.path.exists(file):
              log.error('WorkspaceResult metadata file ['+file+'] not found')
              raise IOError, """WorkspaceResult %s not found!""" % file 
      
          input=open(file,'r')
      
          dom=minidom.parse(input)
      
          # Construct object around DOM.
          workspaceResult=WorkspaceResult()
    
          #
          # Cook the raw model...
          #
          workspaceResult.complete(dom)
  
          return workspaceResult      
  
  
  1.64      +5 -0      jakarta-gump/python/gump/engine.py
  
  Index: engine.py
  ===================================================================
  RCS file: /home/cvs/jakarta-gump/python/gump/engine.py,v
  retrieving revision 1.63
  retrieving revision 1.64
  diff -u -r1.63 -r1.64
  --- engine.py	26 Feb 2004 19:07:55 -0000	1.63
  +++ engine.py	28 Feb 2004 00:08:49 -0000	1.64
  @@ -32,6 +32,7 @@
   from gump.output.statsdb import *
   from gump.output.repository import JarRepository
   from gump.output.nag import nag
  +from gump.result.resulter import generateResults
   from gump.syndication.syndicator import syndicate
   
       
  @@ -154,6 +155,10 @@
           logResourceUtilization('Before syndicate')
           syndicate(run)
                    
  +        #
  +        # Generate results.xml
  +        #
  +        generateResults(run)
           
           #   
           # Build HTML Result (via Forrest or ...)
  
  
  
  1.15      +8 -10     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.14
  retrieving revision 1.15
  diff -u -r1.14 -r1.15
  --- resolver.py	24 Feb 2004 19:32:28 -0000	1.14
  +++ resolver.py	28 Feb 2004 00:08:49 -0000	1.15
  @@ -359,17 +359,15 @@
           self.makePath(path)
           return concatenate(self.xdocsDir,path.serialize())
           
  -    def getAbsoluteFile(self,object,documentName=None,extn='.xml'):
  +    def getAbsoluteFile(self,object,documentName=None,extn='.xml',notXDocs=None):
           location=getLocationForObject(object)
           if documentName: 
               if not documentName.endswith(extn):
                   documentName += extn
               location.setDocument(documentName)
               
  -        # XDocs in one place, content in another
  -        # This is a tad lame, not a great way to detect
  -        # xdocs, but ok for now.
  -        if not extn == '.xml':
  +        # XDocs in one place, content in another...
  +        if not extn == '.xml' or notXDocs:
               self.makePath(location.getPath(),self.contentDir)
               file=concatenate(self.contentDir,location.serialize())
           else:
  @@ -398,8 +396,8 @@
       def getDirectoryUrl(self,object):
           return self.getAbsoluteDirectory(object)
           
  -    def getFile(self,object,documentName=None,extn='.xml'):
  -        return self.getAbsoluteFile(object,documentName,extn)
  +    def getFile(self,object,documentName=None,extn='.xml',notXDocs=None):
  +        return self.getAbsoluteFile(object,documentName,extn,notXDocs)
           
       def getUrl(self,object,documentName=None,extn='.html'):
           return self.getAbsoluteUrl(object,documentName,extn)
  
  
  
  1.17      +7 -4      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.16
  retrieving revision 1.17
  diff -u -r1.16 -r1.17
  --- nag.py	23 Feb 2004 21:55:35 -0000	1.16
  +++ nag.py	28 Feb 2004 00:08:49 -0000	1.17
  @@ -320,7 +320,10 @@
       def getNamedTypedContent(self,object,feedPrefix=None,message=None):
           content="""To whom it may engage...
           
  -This is an automated request, but not an unsolicited one. For help understanding the request please visit http://jakarta.apache.org/gump/nagged.html, and/or contact gump@jakarta.apache.org.
  +This is an automated request, but not an unsolicited one. For help 
  +understanding the request please visit 
  +http://jakarta.apache.org/gump/nagged.html, 
  +and/or contact gump@jakarta.apache.org.
   
   """
       
  
  
  
  1.2       +7 -29     jakarta-gump/python/gump/results/loader.py
  
  Index: loader.py
  ===================================================================
  RCS file: /home/cvs/jakarta-gump/python/gump/results/loader.py,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- loader.py	17 Feb 2004 21:54:21 -0000	1.1
  +++ loader.py	28 Feb 2004 00:08:49 -0000	1.2
  @@ -63,11 +63,11 @@
   """
   import os, os.path
   
  +import xml.dom.minidom
  +
   from gump import log
  -from gump.results.rawmodel import XMLWorkspaceResult,XMLProfileResult,	\
  -            XMLModuleResult, XMLProjectResult
   from gump.results.model import WorkspaceResult
  -from gump.utils.xmlutils import SAXDispatcher
  +
   from gump.utils.note import transferAnnotations, Annotatable
   from gump.utils import dump
   from gump.config import gumpPath
  @@ -94,38 +94,16 @@
           log.error('WorkspaceResult metadata file ['+file+'] not found')
           raise IOError, """WorkspaceResult %s not found!""" % file 
       
  -      #
  -      # Clear out the maps
  -      #
  -    
  -      log.debug("Launch SAX Dispatcher onto : " + file);
  +      log.debug("Launch DOM Parser onto : " + file);
                 
  -      parser=SAXDispatcher(file,'workspaceresult',XMLWorkspaceResult)
  -    
  -      # Extract the root XML
  -      xmlworkspace=parser.docElement
  -    
  -      if not xmlworkspace:
  -        raise IOError, "Failed to load workspace result: " + file
  +      dom=xml.dom.minidom.parse(file)
       
         # Construct object around XML.
  -      workspaceResult=WorkspaceResult(xmlworkspace.name, xmlworkspace)
  -      
  -      # Copy over any XML errors/warnings
  -      transferAnnotations(parser, workspaceResult)
  +      workspaceResult=WorkspaceResult(dom.documentElement.getAttribute('name'),dom)
     
         #
         # Cook the raw model...
         #
  -      workspaceResult.complete(XMLProfileResult.map,	\
  -                          XMLModuleResult.map,	\
  -                          XMLProjectResult.map	)
  -
  -      #
  -      # Clear out the maps [so don't continue to use them]
  -      #
  -      XMLProfileResult.map.clear()
  -      XMLModuleResult.map.clear()
  -      XMLProjectResult.map.clear()
  +      workspaceResult.complete()
         
         return workspaceResult      
  
  
  
  1.2       +69 -99    jakarta-gump/python/gump/results/model.py
  
  Index: model.py
  ===================================================================
  RCS file: /home/cvs/jakarta-gump/python/gump/results/model.py,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- model.py	17 Feb 2004 21:54:21 -0000	1.1
  +++ model.py	28 Feb 2004 00:08:49 -0000	1.2
  @@ -64,18 +64,17 @@
   
   from time import localtime, strftime, tzname
   from string import lower, capitalize
  -
  +from xml.dom.minidom import getDOMImplementation
  +        
   from gump.utils.note import *
   from gump.utils.work import *
   from gump.utils.owner import *
   from gump.model.state import *
   from gump.results.rawmodel import *
   
  -from gump.utils.xmlutils import xmlize
  -
   class ResultModelObject(Annotatable,Ownable,Stateful):
       """Base model object for a single entity"""
  -    def __init__(self,name,xml=None,owner=None):
  +    def __init__(self,name,dom=None,owner=None):
                   
           # Can scribble on this thing...
       	Annotatable.__init__(self)
  @@ -89,9 +88,9 @@
       	# Named
       	self.name=name
       	
  -        # The XML model
  -        if xml:
  -        	self.xml=xml    
  +        # The Dom model
  +        if dom:
  +        	self.dom=dom    
    
           # Internals...
       	self.completionPerformed=0
  @@ -128,27 +127,28 @@
           output.write(getIndent(indent)+'Name: ' + self.name + '\n')
           Annotatable.dump(self,indent,output)
       
  -    def hasXML(self):
  -        if hasattr(self,'xml') and self.xml: return 1
  +    def hasDom(self):
  +        if hasattr(self,'dom') and self.dom: return 1
           return 0
           
  -    def getXML(self):
  -        return self.xml
  -    
  +    def getDom(self):
  +        return self.dom
  +        
       def hasXMLData(self):
           if hasattr(self,'xmldata') and self.xmldata: return 1
  -        return 0
  -        
  +        return 0        
  +    
       def getXMLData(self):
           if not self.hasXMLData():
               stream=StringIO.StringIO() 
               
               # Create on demand (push object attributes
               # into XML form)
  -            if not self.hasXML():
  -                self.createXML()
  +            if not self.hasDom():
  +                self.createDom()
                   
  -            xmlize(self.xml.getTagName(),self.xml,stream)
  +            self.dom.writexml(stream)
  +            
               stream.seek(0)
               self.xmldata=stream.read()
               stream.close()
  @@ -166,8 +166,8 @@
   
   # represents a <workspaceResult/> element
   class WorkspaceResult(ResultModelObject):
  -    def __init__(self,name,xml=None,owner=None):
  -    	ResultModelObject.__init__(self,name,xml,owner)    
  +    def __init__(self,name,dom=None,owner=None):
  +    	ResultModelObject.__init__(self,name,dom,owner)    
       	
       	#
       	# Results per module
  @@ -199,52 +199,36 @@
       def setModuleResult(self,moduleResult):
           self.moduleResults[moduleResult.getName()] = moduleResult
                   
  -        for projectResult in self.getProjectResults():
  +        # Snarf these also, into an ubber map..
  +        for projectResult in moduleResult.getProjectResults():
               self.setProjectResult(projectResult)
           
       def setProjectResult(self,projectResult):
           self.projectResults[projectResult.getName()] = projectResult
           
  -    def createXML(self):
  -        if self.hasXML(): return
  +    def createDom(self):
  +        if self.hasDom(): return
           
  -        """ Convert object attribitues into serializable XML """
  -        self.xml=XMLWorkspaceResult(	\
  -            {	\
  -                'name':self.getName(),	\
  -                'state':self.getStateName(),	\
  -                'reason':self.getReasonName()	\
  -            })
  +        self.dom = getDOMImplementation().createDocument(None, 'workspaceResult', None)
  +        topElement = self.dom.documentElement
  +        
  +        topElement.setAttribute('name',self.getName())
  +        topElement.setAttribute('state',self.getStateName())
  +        topElement.setAttribute('reason',self.getReasonName())
               
           for moduleResult in self.moduleResults.values():
  -            moduleResult.createXML(self.xml)        
  +            moduleResult.createDom(self.dom,topElement)        
                       
  -    def complete(self, xmlprofileresults, xmlmoduleresults,	\
  -                    xmlprojectresults): 
  -        if self.isComplete(): return
  +    def complete(self): 
  +        if self.isComplete() or not self.hasDom(): return
           
           #
           # Import all modules
           #  
  -        for xmlmoduleresult in xmlmoduleresults.values(): 
  -            moduleResult=ModuleResult(xmlmoduleresult.name,xmlmoduleresult,self)
  -            self.setModuleResult(moduleResult)
  -                
  -        #
  -        # Import all projects
  -        #  
  -        for xmlprojectresult in xmlprojectresults.values():             
  -            projectResult=ProjectResult(xmlprojectresult.name,xmlprojectresult,self)
  -            self.setProjectResult(projectResult)
  -
  -        # Complete the modules
  -        for moduleResult in self.getModuleResults():
  -            moduleResult.complete(self)
  -                        
  -        # Complete the projects  
  -        for projectResult in self.getProjectResults():
  -            # Complete the project
  -            projectResult.complete(self)           
  +        for dommoduleresult in self.dom.getElementsByTagName('moduleResult'): 
  +            moduleResult=ModuleResult(dommoduleresult.getAttribute('name'),dommoduleresult,self)
  +            moduleResult.complete()                    
  +            self.setModuleResult(moduleResult)     
           
           self.setComplete(1)
           
  @@ -257,8 +241,8 @@
           
   # represents a <moduleResult/> element
   class ModuleResult(ResultModelObject):
  -    def __init__(self,name,xml=None,owner=None):
  -    	ResultModelObject.__init__(self,name,xml,owner)    
  +    def __init__(self,name,dom=None,owner=None):
  +    	ResultModelObject.__init__(self,name,dom,owner)    
       	
       	# 
       	# Results per project
  @@ -268,7 +252,7 @@
       def setProjectResult(self,projectResult):
           self.projectResults[projectResult.getName()] = projectResult
           # Attach oneself as owner...
  -        projectResult.setModuleResult(self)
  +        projectResult.setOwner(self)
                   
       def hasProjectResults(self):
           if self.projectResults.values(): return 1
  @@ -277,37 +261,27 @@
       def getProjectResults(self):
           return self.projectResults.values()
           
  -    def createXML(self, workspaceResultXML):
  -        if self.hasXML(): return
  +    def createDom(self, document, element):
  +        if self.hasDom(): return
  +        
  +        self.dom = document.createElement('moduleResult')
  +        
  +        self.dom.setAttribute('name',self.getName())
  +        self.dom.setAttribute('state',self.getStateName())
  +        self.dom.setAttribute('reason',self.getReasonName())
           
  -        # This call constructs a new one...
  -        self.xml=workspaceResultXML.moduleResult(	\
  -            {	\
  -                'name':self.getName(),	\
  -                'state':self.getStateName(),	\
  -                'reason':self.getReasonName()	\
  -            })
  +        element.appendChild(self.dom)
               
           for projectResult in self.getProjectResults():
  -            print "CREATE XML FOR :" + `projectResult`
  -            projectResult.createXML(self.xml)
  +            projectResult.createDom(document,self.dom)        
               
  -    def complete(self, workspaceResult): 
  -        if self.isComplete(): return
  -        
  -        for xmlprojectresult in self.xml.projectResult:
  -            if workspaceResult.hasProjectResult(xmlprojectresult.name):
  -                
  -                #
  -                # The project pretty much better be in the
  -                # workspace, but avoid crashing...
  -                #
  -                projectResult=workspaceResult.getProjectResult(xmlprojectresult.name)
  -                
  -                #
  -                # Claim ownership
  -                #
  -                self.setProjectResult(projectResult)
  +    def complete(self): 
  +        if self.isComplete() or not self.hasDom(): return
  +            
  +        for domprojectresult in self.dom.getElementsByTagName('projectResult'):            
  +            projectResult=ProjectResult(domprojectresult.getAttribute('name'),domprojectresult,self)
  +            projectResult.complete()
  +            self.setProjectResult(projectResult)     
                   
           self.setComplete(1)
           
  @@ -320,26 +294,22 @@
               
   # represents a <projectResult/> element
   class ProjectResult(ResultModelObject):
  -    def __init__(self,name,xml=None,owner=None):
  -    	ResultModelObject.__init__(self,name,xml,owner)
  -    	
  -    	self.moduleResult = None
  +    def __init__(self,name,dom=None,owner=None):
  +    	ResultModelObject.__init__(self,name,dom,owner)    
   
  -    def createXML(self, moduleResultXML):
  -        if self.hasXML(): return
  +    def createDom(self, document, element):
  +        if self.hasDom(): return
           
  -        self.xml=moduleResultXML.projectResult(	\
  -            {	\
  -                'name':self.getName(),	\
  -                'state':self.getStateName(),	\
  -                'reason':self.getReasonName()	\
  -            })
  -                
  -    def setModuleResult(self,moduleResult):
  -        self.moduleResult=moduleResult
  +        self.dom = document.createElement('projectResult')
           
  -    def complete(self,workspaceResult): 
  -        if self.isComplete(): return
  +        self.dom.setAttribute('name',self.getName())
  +        self.dom.setAttribute('state',self.getStateName())
  +        self.dom.setAttribute('reason',self.getReasonName())
  +            
  +        element.appendChild(self.dom)
           
  +    def complete(self): 
  +        if self.isComplete(): return
  +    
           self.setComplete(1)
           
  
  
  
  1.2       +3 -2      jakarta-gump/python/gump/results/resulter.py
  
  Index: resulter.py
  ===================================================================
  RCS file: /home/cvs/jakarta-gump/python/gump/results/resulter.py,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- resulter.py	17 Feb 2004 21:54:21 -0000	1.1
  +++ resulter.py	28 Feb 2004 00:08:49 -0000	1.2
  @@ -101,8 +101,7 @@
       def loadResultsForServer(self, server):
           return loadResults(server.getUrl() + '/results.xml')
           
  -    def loadResults(self, url):
  -    
  +    def loadResults(self, url):    
           loader =  WorkspaceResultLoader()        
           return loader.loadFromUrl(url)
           
  @@ -167,6 +166,8 @@
       
       # Generate results around this run...
       resulter=Resulter(run)
  +    
  +    where=run.getOptions().getResolver().getFile(run.getWorkspace(),'results','.xml')
       
       # Generate the output...
       resulter.generateResults()
  
  
  
  1.2       +1 -1      jakarta-gump/python/gump/results/__init__.py
  
  Index: __init__.py
  ===================================================================
  RCS file: /home/cvs/jakarta-gump/python/gump/results/__init__.py,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- __init__.py	17 Feb 2004 21:54:21 -0000	1.1
  +++ __init__.py	28 Feb 2004 00:08:49 -0000	1.2
  @@ -60,4 +60,4 @@
   
   
   # tell Python what modules make up the gump.output package
  -__all__ = ["resulter","module","rawmodel","loader"]
  +__all__ = ["resulter","module","loader"]