gump-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From aj...@apache.org
Subject svn commit: r165133 - in /gump/branches/Gump3/pygump: gump.log.config python/gump/config.py python/gump/engine/__init__.py python/gump/engine/walker.py python/gump/plugins/java/ python/gump/plugins/java/__init__.py python/gump/plugins/java/builder.py python/gump/plugins/logreporter.py
Date Thu, 28 Apr 2005 13:00:18 GMT
Author: ajack
Date: Thu Apr 28 06:00:16 2005
New Revision: 165133

URL: http://svn.apache.org/viewcvs?rev=165133&view=rev
Log:
Start work on ClasspathPlugin and AntPlugin.

Added:
    gump/branches/Gump3/pygump/python/gump/plugins/java/
    gump/branches/Gump3/pygump/python/gump/plugins/java/__init__.py
    gump/branches/Gump3/pygump/python/gump/plugins/java/builder.py
Modified:
    gump/branches/Gump3/pygump/gump.log.config
    gump/branches/Gump3/pygump/python/gump/config.py
    gump/branches/Gump3/pygump/python/gump/engine/__init__.py
    gump/branches/Gump3/pygump/python/gump/engine/walker.py
    gump/branches/Gump3/pygump/python/gump/plugins/logreporter.py

Modified: gump/branches/Gump3/pygump/gump.log.config
URL: http://svn.apache.org/viewcvs/gump/branches/Gump3/pygump/gump.log.config?rev=165133&r1=165132&r2=165133&view=diff
==============================================================================
--- gump/branches/Gump3/pygump/gump.log.config (original)
+++ gump/branches/Gump3/pygump/gump.log.config Thu Apr 28 06:00:16 2005
@@ -26,7 +26,7 @@
 qualname=modeller
 
 [logger_walker]
-level=DEBUG
+level=INFO
 handlers=stdout,filehandler
 propagate=0
 qualname=walker
@@ -42,6 +42,12 @@
 handlers=stdout,filehandler
 propagate=0
 qualname=util.db
+
+[logger_plugin_error-handler]
+level=DEBUG
+handlers=stdout,filehandler
+propagate=0
+qualname=plugin.error-handler
 
 [logger_plugin_dynagumper]
 level=DEBUG

Modified: gump/branches/Gump3/pygump/python/gump/config.py
URL: http://svn.apache.org/viewcvs/gump/branches/Gump3/pygump/python/gump/config.py?rev=165133&r1=165132&r2=165133&view=diff
==============================================================================
--- gump/branches/Gump3/pygump/python/gump/config.py (original)
+++ gump/branches/Gump3/pygump/python/gump/config.py Thu Apr 28 06:00:16 2005
@@ -103,14 +103,18 @@
     from gump.plugins.instrumentation import TimerPlugin
     pre_process_plugins.append(TimerPlugin("run_start"))
     
-    if config.do_update:
+    if config.do_update:    
+        pre_process_plugins.append(TimerPlugin("update_start"))
         from gump.plugins.updater import CvsUpdater, SvnUpdater
-        #pre_process_plugins.append(CvsUpdater(config.paths_work))
-        #pre_process_plugins.append(SvnUpdater(config.paths_work))
-    
+        pre_process_plugins.append(CvsUpdater(config.paths_work))
+        pre_process_plugins.append(SvnUpdater(config.paths_work))
+        pre_process_plugins.append(TimerPlugin("update_end"))
+        
     plugins = []
     # TODO: append more plugins here...
 
+    plugins.append(TimerPlugin("build_start"))
+        
     from gump.plugins import LoggingPlugin
 
     
@@ -124,10 +128,10 @@
     
     from gump.plugins.builder import ScriptBuilderPlugin
     plugins.append(ScriptBuilderPlugin(config.paths_work,buildlog))
-    #from gump.plugins.java.builder import ClasspathPlugin
-    #plugins.append(ClasspathPlugin(config.paths_work,buildlog))
-    #from gump.plugins.java.builder import AntPlugin
-    #plugins.append(AntPlugin(config.paths_work,buildlog))
+    from gump.plugins.java.builder import ClasspathPlugin
+    plugins.append(ClasspathPlugin(config.paths_work,buildlog))
+    from gump.plugins.java.builder import AntPlugin
+    plugins.append(AntPlugin(config.paths_work,buildlog))
     
     post_process_plugins = []
     # TODO: append more plugins here...
@@ -139,11 +143,14 @@
     dynagumplog = get_logger(config, "plugin.dynagumper")
     post_process_plugins.append(Dynagumper(db, dynagumplog))
     
+    plugins.append(TimerPlugin("build_end"))
+
     if config.debug:
         reportlog = get_logger(config, "plugin.logger")
         from gump.plugins.logreporter import LogReporterPlugin
         post_process_plugins.append(LogReporterPlugin(reportlog))
-
+    
+    # Give us an insight to what we have cooking...
     for plugin in pre_process_plugins: log.debug("Preprocessor : %s " % `plugin`)
     for plugin in plugins: log.debug("Processor    : %s " % `plugin`)
     for plugin in post_process_plugins: log.debug("Postprocessor: %s " % `plugin`)
@@ -206,9 +213,14 @@
     """Provide a logging implementation for the given level and name."""
     logging.basicConfig()
     log = logging.getLogger(name)
-    log.setLevel(config.log_level)
+    print 'Got Logger %s for %s' % (log,name)
+    # Let the file decide ... log.setLevel(config.log_level)
     return log
 
+def shutdown_logging():
+    """Perform orderly logging shutdown"""
+    logging.shutdown()
+    
 
 def get_db(log,config):
     """Provide a database implementation."""

Modified: gump/branches/Gump3/pygump/python/gump/engine/__init__.py
URL: http://svn.apache.org/viewcvs/gump/branches/Gump3/pygump/python/gump/engine/__init__.py?rev=165133&r1=165132&r2=165133&view=diff
==============================================================================
--- gump/branches/Gump3/pygump/python/gump/engine/__init__.py (original)
+++ gump/branches/Gump3/pygump/python/gump/engine/__init__.py Thu Apr 28 06:00:16 2005
@@ -109,6 +109,8 @@
     
     # run it
     engine.run()
+    
+    shutdown_logging()
 
 
 def _banner(version):
@@ -221,10 +223,10 @@
             self.workspace_verifier.verify(workspace)
             
             # * Pfew! All done. Now actually start *doing* stuff.
-            self.walker.walk(workspace, self.pre_process_visitor)
+            self.walker.walk(workspace, self.pre_process_visitor, 'pre_process')
             # (visited_repositories, visited_modules, visited_projects) = \
-            self.walker.walk(workspace, self.visitor)
-            self.walker.walk(workspace, self.post_process_visitor)
+            self.walker.walk(workspace, self.visitor, 'process')
+            self.walker.walk(workspace, self.post_process_visitor, 'post_process')
             
             # That's it? Yeah! All other functionality is in the visitors :-D
         except:

Modified: gump/branches/Gump3/pygump/python/gump/engine/walker.py
URL: http://svn.apache.org/viewcvs/gump/branches/Gump3/pygump/python/gump/engine/walker.py?rev=165133&r1=165132&r2=165133&view=diff
==============================================================================
--- gump/branches/Gump3/pygump/python/gump/engine/walker.py (original)
+++ gump/branches/Gump3/pygump/python/gump/engine/walker.py Thu Apr 28 06:00:16 2005
@@ -37,7 +37,7 @@
         
         self.log = log
     
-    def walk(self, workspace, visitor):
+    def walk(self, workspace, visitor, description='unspecified'):
         """Walks a gump tree using inverted topsort.
         
         Arguments:
@@ -51,27 +51,30 @@
         visited_modules = []
         visited_projects = []
 
+        self.log.debug('Visitor %s initialize, on %s walk.' % (`visitor`, description))
         visitor._initialize()
         
-        self.log.debug('Visit W/S : ' + `workspace`)
+        self.log.debug('Visit W/S %s for %s walk.' % (`workspace`, description))
         visitor._visit_workspace(workspace)
         list = self._topsort_projects(workspace)
         
         for project in list:
             if not project.module in visited_modules:
                 if not project.module.repository in visited_repositories:
-                    self.log.debug('Visit Repo : ' + `project.module.repository`)
+                    self.log.debug('Visit Repo %s for %s walk.' % \
+                                   (`project.module.repository`, description))
                     visitor._visit_repository(project.module.repository)
                     visited_repositories.append(project.module.repository)
                     
-                self.log.debug('Visit Module : ' + `project.module`)
+                self.log.debug('Visit Module %s for %s walk.' % (`project.module`,description))
                 visitor._visit_module(project.module)
                 visited_modules.append(project.module)
             
-            self.log.debug('Visit Project : ' + `project`)
+            self.log.debug('Visit Project %s for %s walk.' % (`project`, description))
             visitor._visit_project(project)
             visited_projects.append(project)
         
+        self.log.debug('Visitor %s finalize, on %s walk.' % (`visitor`, description))
         visitor._finalize()
         return (visited_repositories, visited_modules, visited_projects)
     

Added: gump/branches/Gump3/pygump/python/gump/plugins/java/__init__.py
URL: http://svn.apache.org/viewcvs/gump/branches/Gump3/pygump/python/gump/plugins/java/__init__.py?rev=165133&view=auto
==============================================================================
--- gump/branches/Gump3/pygump/python/gump/plugins/java/__init__.py (added)
+++ gump/branches/Gump3/pygump/python/gump/plugins/java/__init__.py Thu Apr 28 06:00:16 2005
@@ -0,0 +1,16 @@
+#!/usr/bin/env python
+
+# Copyright 2004-2005 The Apache Software Foundation
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+# 
+#     http://www.apache.org/licenses/LICENSE-2.0
+# 
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+""" Contains Java specific Classes/Plugins """
\ No newline at end of file

Added: gump/branches/Gump3/pygump/python/gump/plugins/java/builder.py
URL: http://svn.apache.org/viewcvs/gump/branches/Gump3/pygump/python/gump/plugins/java/builder.py?rev=165133&view=auto
==============================================================================
--- gump/branches/Gump3/pygump/python/gump/plugins/java/builder.py (added)
+++ gump/branches/Gump3/pygump/python/gump/plugins/java/builder.py Thu Apr 28 06:00:16 2005
@@ -0,0 +1,235 @@
+#!/usr/bin/env python
+
+# Copyright 2004-2005 The Apache Software Foundation
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+# 
+#     http://www.apache.org/licenses/LICENSE-2.0
+# 
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+__copyright__ = "Copyright (c) 2004-2005 The Apache Software Foundation"
+__license__   = "http://www.apache.org/licenses/LICENSE-2.0"
+
+import os
+import sys
+from os.path import abspath, join, isfile
+
+from gump.model import Script, Error, Project, Ant, Dependency, Homedir, Jar
+from gump.model.util import get_project_directory
+from gump.plugins import AbstractPlugin
+from gump.util.executor import Popen, PIPE, STDOUT
+
+class BuilderPlugin(AbstractPlugin):
+    """Execute all commands for all projects."""
+    def __init__(self, workdir, log, cmd_clazz, method):
+        self.workdir = workdir
+        self.log = log
+        self.cmd_clazz = cmd_clazz
+        self.method = method             
+
+    def visit_project(self, project):
+        """ Dispatch for each matching command (matching by class type) """        
+        assert isinstance(project, Project)
+        self.log.debug("Visit %s looking for %s" % (project,self.cmd_clazz))
+        for command in [command for command in project.commands if isinstance(command,self.cmd_clazz)]:
+            try:        
+                self.log.debug("Perform %s on %s" % (command, project))
+                self.method(project, command)
+            except Exception:
+                self.log.exception("Failed...")
+
+
+class ArtifactPath(object):
+    """Represents an artifact within a path"""
+    def __init__(self,id,path,description=None):
+        self.id=id
+        self.path = path
+        self.description=description
+        
+    def __eq__(self,other):
+        return (self.path == other.path)
+    
+    def __str__(self):
+        return self.path
+        
+class Classpath(object):
+    """Represents a list of artifacts
+
+    Has the following properties:
+        
+        - id -- identifier
+        - parts -- an array of ArtifactPath objects
+        - state -- state of Artifacts:
+                    unknown
+                    complete
+                    stale (some from repository)
+                    incomplete (some missing)"""
+    def __init__(self, id):
+        self.id = id
+        self.parts = []
+        self.state='unknown'
+    
+    def __add__(self,other):
+        if not isinstance(other,ArtifactPath):
+             other=ArtifactPath("Unknown",other,"Unspecified")
+        if not other in self.parts:
+            self.parts.append(other)
+        return self
+    
+    def __str__(self):
+        import string
+        return string.join([ part.path for part in self.parts ], os.pathsep)
+    
+class ClasspathPlugin(BuilderPlugin):
+    """Generate build attributes (e.g. CLASSAPATH) for a builder."""
+    def __init__(self, workdir, log):
+        BuilderPlugin.__init__(self, workdir, log, Ant, self._forge_classpaths)
+        
+    def _forge_classpaths(self, project, ant):               
+
+        # Stub them out...
+        ant.classpath=Classpath("Standard")
+        ant.boot_classpath=Classpath("Boot")
+        
+        # Flesh them out...
+        self._calculateClasspaths(project,ant)
+
+    def _calculateClasspaths(self, project, ant):
+        """Generate the classpath lists"""
+        #TODO This ought be under "java" not under "Ant".        
+        
+        #TODO Need "<work> elements
+        
+        # Recurse into dependencies
+        visited=[]
+        for dependency in project.dependencies:
+            self._calculateDependencyContributions(ant,dependency,1,visited)
+            
+    def _calculateDependencyContributions(self,ant,dependency,depth,visited):        
+        assert isinstance(dependency, Dependency)
+        
+        #TODO Check NO_CLASSPATH if dependency.dependencyInfo
+        if dependency in visited: return
+
+        # Access the players
+        project=dependency.dependency
+        projectpath = get_project_directory(self.workdir,project)
+        
+        #TODO Do we need a filter here? Are all dependency infos
+        # appropriate, or not?
+        for info in [info for info in dependency.dependencyInfo]:           
+                    
+            # The dependency drivers...
+            #
+            # runtime (i.e. this is a runtime dependency)
+            # inherit (i.e. inherit stuff from a dependency)
+            # ids (i.e. what output ids to select)
+            #
+            runtime=info.runtime
+            inherit=info.inherit
+            ids=info.specific_output_ids
+      
+            # Explain..
+            depend_str=''
+            if inherit: 
+                if depend_str: depend_str += ', '
+                depend_str += 'Inherit:'+dependency.inherit
+            if runtime: 
+                if depend_str: depend_str += ', '
+                depend_str += 'Runtime'
+            
+            # Append Outputs for this project
+            #    (respect ids --- none means 'all)
+            project_ids=[]
+            for output in project.outputs:
+                # Store for double checking
+                if output.id: project_ids.append(output.id)
+                
+                # If 'all' or in ids list:
+                if (not ids) or (output.id in ids):   
+                    if ids: depend_str += ' ID = ' + output.id
+                    
+                    if isinstance(output,Homedir):
+                        path = os.path.join(projectpath,output.directory)
+                    elif isinstance(output,Jar):
+                        path = os.path.join(projectpath,output.name)
+                    else:
+                        raise Error, "Unknown Output Type for %s: %s" % (self.__class__.__name__,
output.__class__.__name__)
+                    
+                    artifact_path=ArtifactPath(output.id,path,depend_str) 
+              
+                    # Add to CLASSPATH (or BOOTCLASSPATH)
+                    if not isinstance(output,Jar) or not output.add_to_bootclass_path:
+                        ant.classpath += artifact_path
+                    else:
+                        ant.boot_classpath += artifact_path
+
+        # Double check IDs (to reduce stale IDs in metadata)
+        if ids:
+            for id in ids:
+                if not id in project_ids:
+                    self.log.warn("Invalid ID [" + id + "] for dependency on [" + project.name
+ "]")
+
+        visited.append(dependency)  
+        
+        # Append sub-projects outputs, if inherited
+        for subdependency in project.dependencies:        
+            #
+            # 	For the main project we working on, we care about it's request for inheritence
+            #	but we don't recursively inherit. (i.e. we only do this at recursion depth
1).
+            #
+            #   If the dependency is set to 'all' (or 'hard') we inherit all dependencies.
+            # 	If the dependency is set to 'runtime' we inherit all runtime dependencies.
+            #
+            #	INHERIT_OUTPUTS (aka INHERIT_JARS) is more sticky, and we track that down (and
down, ...).
+            #
+            for subinfo in subdependency.dependencyInfo:
+                if   (  ( ( 1 == depth ) and \
+                        (inherit in [ 'all', 'hard' ]) \
+                    or \
+                          (inherit == 'runtime' and subdependency.isRuntime()) ) \
+                    or \
+                        ( inherit in [ 'outputs' ] ) ) :      
+                    self._calculateDependencyContributions(ant,subdependency,depth+1,visited)
+                    
+        
+class ArtifactPlugin(BuilderPlugin):
+    """Resolve all entries in the CLASSPATH|BOOT_CLASSPATH checking for existence. 
+    When absent see if recent copies can be acquired from a repository."""
+    def __init__(self,workdir, log):
+        BuilderPlugin.__init__(self, workdir, log, Ant, self._resolve_classpaths)
+        
+    def _resolve_classpaths(self, project, ant):           
+        
+        projectpath = get_project_directory(self.workdir,project)
+        
+        self._resolve_classpath(ant.classpath)
+        self._resolve_classpath(ant.boot_classpath)
+        
+    def _resolve_classpath(classpath):        
+        for artifact_path in ant.classpath:
+            if not os.path.exists(artifact_path.path):
+                #TODO Go find from Repository...
+                classpath.state='incomplete'
+        
+class AntPlugin(BuilderPlugin):
+    """Execute all "ant" commands for all projects."""
+    def __init__(self, workdir, log):
+        BuilderPlugin.__init__(self, workdir, log, Ant, self._do_ant)
+        
+    def _do_ant(self, project, ant):                
+        projectpath = get_project_directory(self.workdir,project)
+        
+        buildfile = abspath(join(projectpath, ant.name))        
+        
+        #TODO
+        import pprint
+        self.log.debug('CLASSPATH %s' % ant.classpath)
+        self.log.debug('BOOTCLASSPATH %s' % ant.boot_classpath)

Modified: gump/branches/Gump3/pygump/python/gump/plugins/logreporter.py
URL: http://svn.apache.org/viewcvs/gump/branches/Gump3/pygump/python/gump/plugins/logreporter.py?rev=165133&r1=165132&r2=165133&view=diff
==============================================================================
--- gump/branches/Gump3/pygump/python/gump/plugins/logreporter.py (original)
+++ gump/branches/Gump3/pygump/python/gump/plugins/logreporter.py Thu Apr 28 06:00:16 2005
@@ -36,12 +36,15 @@
         if container:
             if hasattr(container, "name"):
                 name = "%s:%s" % (container.name, name)
-
+                
+        #self.log.debug(name)
         for attribute in dir(object):
             if attribute.endswith("_log"):
                 logmsg = getattr(object,attribute)
                 self.log.debug("---%s.%s----------------------------------:\n%s" % (name,
attribute, logmsg))
                 self.log.debug(hr)
+            #else:
+            #    self.log.debug(' %s -> %s' % (attribute,getattr(object,attribute)))
 
         if hasattr(object, 'exceptions'):
             import StringIO
@@ -63,3 +66,7 @@
         self._do_visit(project)
         for command in project.commands:
             self._do_visit(command,project)
+            
+    def finalize(self):
+        self.log.debug('  Finished Outputting all log data (a lot)...')
+        self.log.debug(hr)



Mime
View raw message