gump-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From leosim...@apache.org
Subject svn commit: r124570 - in gump/branches/Gump3/pygump/python/gump: . engine model plugins
Date Fri, 07 Jan 2005 20:24:18 GMT
Author: leosimons
Date: Fri Jan  7 12:24:15 2005
New Revision: 124570

URL: http://svn.apache.org/viewcvs?view=rev&rev=124570
Log:
Some bugfixes and some demo code.

* I first had the walker 'the other way around', producing a list of projects order by number
of dependencies, which is kind annoying because of the need to call reverse(). I fixed only
half of that, so it was a mess. It seems to work better now, but the sorting stuff really
needs testcases.

* I added in some demo instrumentation and dynagump sql commands.

* the walker is now logging. Its real annoying that the arguments send to the get_xxx methods
in config need to be updated in main and vice versa. Need to change that.

* probably more small changes :-D
Modified:
   gump/branches/Gump3/pygump/python/gump/config.py
   gump/branches/Gump3/pygump/python/gump/engine/__init__.py
   gump/branches/Gump3/pygump/python/gump/engine/modeller.py
   gump/branches/Gump3/pygump/python/gump/engine/walker.py
   gump/branches/Gump3/pygump/python/gump/model/__init__.py
   gump/branches/Gump3/pygump/python/gump/plugins/dynagumper.py

Modified: gump/branches/Gump3/pygump/python/gump/config.py
Url: http://svn.apache.org/viewcvs/gump/branches/Gump3/pygump/python/gump/config.py?view=diff&rev=124570&p1=gump/branches/Gump3/pygump/python/gump/config.py&r1=124569&p2=gump/branches/Gump3/pygump/python/gump/config.py&r2=124570
==============================================================================
--- gump/branches/Gump3/pygump/python/gump/config.py	(original)
+++ gump/branches/Gump3/pygump/python/gump/config.py	Fri Jan  7 12:24:15 2005
@@ -87,20 +87,24 @@
     pre_process_plugins = []
     # TODO: append more plugins here...
     
+    from gump.plugins.instrumentation import TimerPlugin
+    pre_process_plugins.append(TimerPlugin("run_start"))
+    
     plugins = []
+    # TODO: append more plugins here...
 
     from gump.plugins import LoggingPlugin
     log = get_logger(config.log_level, "plugin-log")
     plugins.append(LoggingPlugin(log))
     
+    post_process_plugins = []
+    # TODO: append more plugins here...
+    post_process_plugins.append(TimerPlugin("run_end"))
+
     from gump.plugins.dynagumper import Dynagumper
     db = get_db(config)
     log = get_logger(config.log_level, "plugin-dynagumper")
-    plugins.append(Dynagumper(db, log))
-    # TODO: append more plugins here...
-    
-    post_process_plugins = []
-    # TODO: append more plugins here...
+    post_process_plugins.append(Dynagumper(db, log, "run_start", "run_end"))
     
     return (pre_process_plugins, plugins, post_process_plugins)
 
@@ -202,10 +206,12 @@
     return Verifier()
 
 
-def get_walker():
+def get_walker(config):
     """Provide a Walker implementation."""
     from gump.engine.walker import Walker
-    return Walker()
+    
+    log = get_logger(config.log_level, "walker")
+    return Walker(log)
 
 
 def get_plugin(config):

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?view=diff&rev=124570&p1=gump/branches/Gump3/pygump/python/gump/engine/__init__.py&r1=124569&p2=gump/branches/Gump3/pygump/python/gump/engine/__init__.py&r2=124570
==============================================================================
--- gump/branches/Gump3/pygump/python/gump/engine/__init__.py	(original)
+++ gump/branches/Gump3/pygump/python/gump/engine/__init__.py	Fri Jan  7 12:24:15 2005
@@ -59,6 +59,8 @@
     Arguments:
       - settings -- everything the engine needs to know about the environment.
     """
+    #TODO: normalize this so that main() isn't responsible for feeding specific
+    # arguments into the _get_xxx() methods. Its annoying.
     
     # ooh...ah...fancy :-D
     _banner(settings.version)
@@ -83,7 +85,7 @@
     mergefile = os.path.join(config.paths_work, "merge.xml")
     dropfile = os.path.join(config.paths_work, "dropped.xml")
     
-    walker = get_walker()
+    walker = get_walker(config)
     (pre_process_visitor, visitor, post_process_visitor) = get_plugin(config)
     
     # create engine

Modified: gump/branches/Gump3/pygump/python/gump/engine/modeller.py
Url: http://svn.apache.org/viewcvs/gump/branches/Gump3/pygump/python/gump/engine/modeller.py?view=diff&rev=124570&p1=gump/branches/Gump3/pygump/python/gump/engine/modeller.py&r1=124569&p2=gump/branches/Gump3/pygump/python/gump/engine/modeller.py&r2=124570
==============================================================================
--- gump/branches/Gump3/pygump/python/gump/engine/modeller.py	(original)
+++ gump/branches/Gump3/pygump/python/gump/engine/modeller.py	Fri Jan  7 12:24:15 2005
@@ -973,6 +973,7 @@
             dependency_project = dependency_name
         
         id = dependency.getAttribute("id")
+        new_dependency = Dependency(dependency_project,project,optional,runtime,inherit,id)
         project.add_dependency(Dependency(dependency_project,project,optional,runtime,inherit,id))
 
 

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?view=diff&rev=124570&p1=gump/branches/Gump3/pygump/python/gump/engine/walker.py&r1=124569&p2=gump/branches/Gump3/pygump/python/gump/engine/walker.py&r2=124570
==============================================================================
--- gump/branches/Gump3/pygump/python/gump/engine/walker.py	(original)
+++ gump/branches/Gump3/pygump/python/gump/engine/walker.py	Fri Jan  7 12:24:15 2005
@@ -30,6 +30,10 @@
     Note that the walker will fail to visit all projects if there is a cyclic
     dependency somewhere.
     """
+    def __init__(self, log):
+        self.log = log
+        self.no_debug = False
+        self.visited_workspaces = []
     
     def walk(self, workspace, visitor):
         """Walks a gump tree using inverted topsort.
@@ -41,11 +45,29 @@
         Returns a tuple containing the repositories visited, the modules
         visited, and the projects visited, in the order they were visited.
         """
+        if workspace in self.visited_workspaces: # only debug once...
+            self.no_debug = True
+        self.visited_workspaces.append(workspace)
+        
         visitor._initialize()
         visitor._visit_workspace(workspace)
         
+        if not self.no_debug:
+            names = ""
+            for project in workspace.projects.values():
+                names += project.name + ", "
+            names = names[:-2]
+            self.log.debug("Projects to sort:\n%s" % names)
+        
         list = self._topsort_projects(workspace)
         
+        if not self.no_debug:
+            names = ""
+            for project in list:
+                names += project.name + ", "
+            names = names[:-2]
+            self.log.debug("Topological sort of projects results in:\n%s" % names)
+        
         visited_repositories = []
         visited_modules = []
         visited_projects = []
@@ -80,10 +102,10 @@
             project = stack.pop()
             list.append(project)
             
-            for dependency in project.dependencies:
-                dependency.dependee.indegree -= 1
-                if dependency.dependee.indegrees == 0:
-                    stack.append(dependency.dependee)
+            for dependee in project.dependees:
+                dependee.dependee.indegree -= 1
+                if dependee.dependee.indegree == 0:
+                    stack.append(dependee.dependee)
     
         self._clear_indegrees(workspace)
         return list

Modified: gump/branches/Gump3/pygump/python/gump/model/__init__.py
Url: http://svn.apache.org/viewcvs/gump/branches/Gump3/pygump/python/gump/model/__init__.py?view=diff&rev=124570&p1=gump/branches/Gump3/pygump/python/gump/model/__init__.py&r1=124569&p2=gump/branches/Gump3/pygump/python/gump/model/__init__.py&r2=124570
==============================================================================
--- gump/branches/Gump3/pygump/python/gump/model/__init__.py	(original)
+++ gump/branches/Gump3/pygump/python/gump/model/__init__.py	Fri Jan  7 12:24:15 2005
@@ -240,9 +240,9 @@
     def add_dependency(self, dependency):
         self.module.repository.workspace.dependencies.append(dependency)
         self.dependencies.append(dependency)
-        if type(dependency.dependee) == Project: # might be a string for a bad
-                                                 # dependency
-            dependency.dependee.add_dependee(dependency)
+        if type(dependency.dependency) == type(self): # might be a string for a bad
+                                                      # dependency
+            dependency.dependency.add_dependee(dependency)
     
     def add_dependee(self, dependee):
         self.dependees.append(dependee)
@@ -272,11 +272,11 @@
     
     Has the following properties:
         
-        - dependency -- the project that is depending on the other project
-        - dependee   -- the project that is being depended on by the
+        - dependency -- the project that is being depended on by the
                         other project, or the name of that project if
                         it doesn't actually exist (ie that's an error
                         condition).
+        - dependee -- the project that is depending on the other project
         - optional   -- flag indicating whether the dependee can be built and
                         used if this dependency cannot be satisfied
         - runtime    -- flag indicating whether the dependee needs this

Modified: gump/branches/Gump3/pygump/python/gump/plugins/dynagumper.py
Url: http://svn.apache.org/viewcvs/gump/branches/Gump3/pygump/python/gump/plugins/dynagumper.py?view=diff&rev=124570&p1=gump/branches/Gump3/pygump/python/gump/plugins/dynagumper.py&r1=124569&p2=gump/branches/Gump3/pygump/python/gump/plugins/dynagumper.py&r2=124570
==============================================================================
--- gump/branches/Gump3/pygump/python/gump/plugins/dynagumper.py	(original)
+++ gump/branches/Gump3/pygump/python/gump/plugins/dynagumper.py	Fri Jan  7 12:24:15 2005
@@ -26,7 +26,7 @@
     Populate the DynaGump run metadata database.
     """
     
-    def __init__(self, db, log):
+    def __init__(self, db, log, startdate_property_name, enddate_property_name):
         """Set up the Dynagumper.
 
         Arguments:
@@ -36,6 +36,9 @@
         self.db = db
         self.log = log
         
+        self.startdate_property_name = startdate_property_name
+        self.enddate_property_name = enddate_property_name
+        
     def initialize(self):
         #TODO call ensureThisHostIsInDatabase
         pass
@@ -62,5 +65,16 @@
     
     def visit_project(self, project):    
         """Add information about a project to the database."""
-        pass
+        tablename = "projects"
+        startdate = getattr(project, self.startdate_property_name)
+        enddate = getattr(project, self.enddate_property_name)
+        name = project.name
+        
+        cmd = "INSERT INTO %s (project_name, start_date, end_date) VALUES ('%s', '%s', '%s')"
\
+            % (tablename, name, startdate, enddate)
+        
+        #TODO make query fit database model
+        self.log.debug("Executing SQL: %s" % cmd)
+        # self.db.execute(cmd)
+        
         #TODO do the actual work right here...

Mime
View raw message