gump-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From leosim...@apache.org
Subject svn commit: r209595 - in /gump/branches/Gump3/pygump/python/gump: config.py plugins/builder.py plugins/environment.py plugins/java/builder.py test/testPluginBuilder.py
Date Thu, 07 Jul 2005 12:36:40 GMT
Author: leosimons
Date: Thu Jul  7 05:36:38 2005
New Revision: 209595

URL: http://svn.apache.org/viewcvs?rev=209595&view=rev
Log:
Implement an EnvironmentPlugin, GUMP-121, and start using it.

* pygump/python/gump/plugins/environment.py: a new plugin which uses python properties to
lazily add a per-project custom environment dictionary as it is needed by various builders.

* pygump/python/gump/config.py: enable the new environment plugin.

* pygump/python/gump/test/testPluginBuilder.py,
  pygump/python/gump/plugins/java/builder.py.
  pygump/python/gump/plugins/builder.py: change existing builders to use the new EnvironmentPlugin.

Added:
    gump/branches/Gump3/pygump/python/gump/plugins/environment.py
      - copied, changed from r209586, gump/branches/Gump3/pygump/python/gump/plugins/introspection.py
Modified:
    gump/branches/Gump3/pygump/python/gump/config.py
    gump/branches/Gump3/pygump/python/gump/plugins/builder.py
    gump/branches/Gump3/pygump/python/gump/plugins/java/builder.py
    gump/branches/Gump3/pygump/python/gump/test/testPluginBuilder.py

Modified: gump/branches/Gump3/pygump/python/gump/config.py
URL: http://svn.apache.org/viewcvs/gump/branches/Gump3/pygump/python/gump/config.py?rev=209595&r1=209594&r2=209595&view=diff
==============================================================================
--- gump/branches/Gump3/pygump/python/gump/config.py (original)
+++ gump/branches/Gump3/pygump/python/gump/config.py Thu Jul  7 05:36:38 2005
@@ -106,6 +106,8 @@
     
     from gump.plugins.instrumentation import TimerPlugin
     pre_process_plugins.append(TimerPlugin("run_start"))
+    from gump.plugins.environment import EnvironmentPlugin
+    pre_process_plugins.append(EnvironmentPlugin())
     
     plugins = []
 

Modified: gump/branches/Gump3/pygump/python/gump/plugins/builder.py
URL: http://svn.apache.org/viewcvs/gump/branches/Gump3/pygump/python/gump/plugins/builder.py?rev=209595&r1=209594&r2=209595&view=diff
==============================================================================
--- gump/branches/Gump3/pygump/python/gump/plugins/builder.py (original)
+++ gump/branches/Gump3/pygump/python/gump/plugins/builder.py Thu Jul  7 05:36:38 2005
@@ -78,7 +78,7 @@
                 raise Error, "No script '%s' found!" % scriptfile
         
         args = [scriptfile] + script.args
-        cmd = Popen(args,shell=True,cwd=projectpath,stdout=PIPE,stderr=STDOUT)
+        cmd = Popen(args,shell=True,cwd=projectpath,stdout=PIPE,stderr=STDOUT,env=project.env)
         
         script.build_log = cmd.communicate()[0]
         script.build_exit_status = cmd.wait()

Copied: gump/branches/Gump3/pygump/python/gump/plugins/environment.py (from r209586, gump/branches/Gump3/pygump/python/gump/plugins/introspection.py)
URL: http://svn.apache.org/viewcvs/gump/branches/Gump3/pygump/python/gump/plugins/environment.py?p2=gump/branches/Gump3/pygump/python/gump/plugins/environment.py&p1=gump/branches/Gump3/pygump/python/gump/plugins/introspection.py&r1=209586&r2=209595&rev=209595&view=diff
==============================================================================
--- gump/branches/Gump3/pygump/python/gump/plugins/introspection.py (original)
+++ gump/branches/Gump3/pygump/python/gump/plugins/environment.py Thu Jul  7 05:36:38 2005
@@ -17,87 +17,29 @@
 __copyright__ = "Copyright (c) 2004-2005 The Apache Software Foundation"
 __license__   = "http://www.apache.org/licenses/LICENSE-2.0"
 
-import platform
-
+import os
+from gump.model import Project
 from gump.plugins import AbstractPlugin
 
-class IntrospectionPlugin(AbstractPlugin):
-    """Print out a what the workspace looks like. Useful for debugging."""
-    def __init__(self, log):
-        self.log = log
+def __get_env(self):
+    # start copying the existing environment from the OS
+    if not hasattr(self, "__env"):
+        self.__env = dict(os.environ)
         
-    def finalize(self, workspace):
-        msg = "Workspace properties:\n   "
-        properties = [prop for prop in dir(workspace) if not prop.startswith("__")]
-        properties.sort()
-        msg += "\n   ".join(properties)
-
-        allproperties = []
-        for v in workspace.repositories.values():
-            properties = [prop for prop in dir(v) if not prop.startswith("__") and not prop
in allproperties]
-            allproperties.extend(properties)
-        allproperties.sort()
-        msg += "\n\nAll possible repository properties:\n   "
-        msg += "\n   ".join(allproperties)
-
-        allproperties = []
-        for v in workspace.modules.values():
-            properties = [prop for prop in dir(v) if not prop.startswith("__") and not prop
in allproperties]
-            allproperties.extend(properties)
-        allproperties.sort()
-        msg += "\n\nAll possible module properties:\n   "
-        msg += "\n   ".join(allproperties)
-
-        allproperties = []
-        for v in workspace.projects.values():
-            properties = [prop for prop in dir(v) if not prop.startswith("__") and not prop
in allproperties]
-            allproperties.extend(properties)
-        allproperties.sort()
-        msg += "\n\nAll possible project properties:\n   "
-        msg += "\n   ".join(allproperties)
-
-        allproperties = []
-        for v in workspace.projects.values():
-            for c in v.commands:
-                properties = [prop for prop in dir(c) if not prop.startswith("__") and not
prop in allproperties]
-                allproperties.extend(properties)
-        allproperties.sort()
-        msg += "\n\nAll possible command properties:\n   "
-        msg += "\n   ".join(allproperties)
+    return self.__env
 
-        msg += "\n\nAll known repositories:\n"
-        for k in workspace.repositories.keys():
-            msg += "   %s\n" % k
+def __set_env(self, env):
+        self.__env = env
 
-        msg += "\nAll known modules:\n"
-        for k in workspace.modules.keys():
-            msg += "   %s\n" % k
-
-        msg += "\nAll known projects:\n"
-        for k in workspace.modules.keys():
-            msg += "   %s\n" % k
-        
-        self.log.debug("=" * 78)
-        self.log.debug(msg)
-        self.log.debug("=" * 78)
-        
-        # Example of how you can "probe" into specific parts of the model
-        # if you want...
-        #
-        #xmlapis = workspace.projects["xml-apis"]
-        #for prop in dir(xmlapis):
-        #    att = getattr(xmlapis, prop)
-        #    if callable(att):
-        #        continue
-        #    self.log.debug("XML-APIS attribute %s has value %s" % (prop, att))
-        
-        #bootstrapant = workspace.projects["bootstrap-ant"]
-        #for c in bootstrapant.commands:
-        #    from gump.model import Script
-        #    if isinstance(c, Script):
-        #        for p in dir(c):
-        #            att = getattr(c, p)
-        #            if callable(att):
-        #                continue
-        #            self.log.debug("BOOTSTRAP-ANT command attribute %s has value %s" % (p,
att))
+def __del_env(self):
+    del self.__env
 
+class EnvironmentPlugin(AbstractPlugin):
+    """Set up lazily-initialized environment dictionary for use with executed commands."""
+    
+    def __init__(self):
+        pass
+    
+    def initialize(self):
+        Project.env = property(__get_env, __set_env, __del_env,
+            "Environment dictionary for use with command execution")

Modified: 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=209595&r1=209594&r2=209595&view=diff
==============================================================================
--- gump/branches/Gump3/pygump/python/gump/plugins/java/builder.py (original)
+++ gump/branches/Gump3/pygump/python/gump/plugins/java/builder.py Thu Jul  7 05:36:38 2005
@@ -46,9 +46,6 @@
     def __init__(self, workdir, log, debug=False):
         BuilderPlugin.__init__(self, workdir, log, Ant, self._do_ant)
         self.debug = debug
-
-        # Clone the environment, so we can squirt CLASSPATH into it.
-        self.tmp_env = dict(os.environ)
         
     def _do_ant(self, project, ant):                
         projectpath = get_project_directory(self.workdir,project)
@@ -57,7 +54,7 @@
         self.log.debug('BOOTCLASSPATH %s' % ant.boot_classpath)
         
         # Create an Environment
-        self.tmp_env['CLASSPATH'] = str(ant.classpath)
+        project.env['CLASSPATH'] = str(ant.classpath)
         
         # TODO test this
         # TODO sysclasspath only
@@ -85,7 +82,7 @@
         self.log.debug("Command : %s " % (args))
         self.log.debug("        : %s " % ant.classpath)
         #self.log.debug("        : %s " % self.tmp_env)
-        cmd = Popen(args,shell=False,cwd=projectpath,stdout=PIPE,stderr=STDOUT,env=self.tmp_env)
+        cmd = Popen(args,shell=False,cwd=projectpath,stdout=PIPE,stderr=STDOUT,env=project.env)
 
         ant.build_log = cmd.communicate()[0]
         ant.build_exit_status = cmd.wait()

Modified: gump/branches/Gump3/pygump/python/gump/test/testPluginBuilder.py
URL: http://svn.apache.org/viewcvs/gump/branches/Gump3/pygump/python/gump/test/testPluginBuilder.py?rev=209595&r1=209594&r2=209595&view=diff
==============================================================================
--- gump/branches/Gump3/pygump/python/gump/test/testPluginBuilder.py (original)
+++ gump/branches/Gump3/pygump/python/gump/test/testPluginBuilder.py Thu Jul  7 05:36:38 2005
@@ -48,6 +48,7 @@
             mpath = join(basedir,w.name,r.name,m.name)
             mkdir(mpath)
             p = Project(m,"p")
+            p.env = os.environ
             if sys.platform == "win32":
                 scriptpath = join(mpath,"dobuild.bat")
                 scriptfile = open(scriptpath, mode='w')



Mime
View raw message