gump-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From leosim...@apache.org
Subject svn commit: r168384 - in /gump/branches/Gump3: ./ pygump/ pygump/python/gump/ pygump/python/gump/engine/ pygump/python/gump/model/ pygump/python/gump/plugins/ pygump/python/gump/util/
Date Thu, 05 May 2005 18:53:34 GMT
Author: leosimons
Date: Thu May  5 11:53:33 2005
New Revision: 168384

URL: http://svn.apache.org/viewcvs?rev=168384&view=rev
Log:
Do a lot of work to improve console output, fixing a few TODOs and/or inconsitencies in the
process.

* pygump/python/gump/model/util.py: fix the cause-checking code to be more robust.

* pygump/python/gump/model/__init__.py: add __str__ methods for all model objects to make
logs more readable.

* pygump/python/gump/plugins/logreporter.py: add a new reporter which provides a nice activity
overview and prettify the others.

* pygump/python/gump/plugins/builder.py: stop the abstract BuilderPlugin from eating up exceptions.
Plugins should let exceptions cascade upward if 
they don't know how to recover.

* pygump/python/gump/engine/__init__.py: some "pretty printing" changes.

* pygump/python/gump/engine/algorithm.py: make the "smarter" algorithm actually work, but
disable the update-checking for now as it hampers 
development ("nothing happened!"). Add a new ExceptionInfo class to have stronger typing during
error handling. Implement a little pretty printing.

* pygump/python/gump/config.py: sync with changes to other files. Start using the more efficient
algorithm for the "main" plugin run, configure 
logging using different files (one for debugging, one regular), start using the new logging
plugins.

* pygump/python/gump/util/executor.py: prettify logging.

* pygump/python/gump/util/__init__.py: provide a dead-simple utility for doing colored output
on ansi-compatible terminals.

* pygump/python/gump/util/mysql: prettify logging.

* pygump/gump.log.config.debug: new logging configuration for use with the --debug flag.

* pygump/main.py: make the changed defaults for logging and updating more permanent and less
confusing, renaming --no-updates to --do-updates. Add a 
new --enable-colors flag that can be used on ansi terminals to get colored output (both to
the console and into log files).

* pygump/gump.log.config: make default logging less verbose (use --debug for verbose logging).

* gump: disable the "pycompile" step during gump runs to avoid most of the puzzling startup
delay.

Added:
    gump/branches/Gump3/pygump/gump.log.config.debug
      - copied, changed from r168314, gump/branches/Gump3/pygump/gump.log.config
Modified:
    gump/branches/Gump3/gump
    gump/branches/Gump3/pygump/gump.log.config
    gump/branches/Gump3/pygump/main.py
    gump/branches/Gump3/pygump/python/gump/config.py
    gump/branches/Gump3/pygump/python/gump/engine/__init__.py
    gump/branches/Gump3/pygump/python/gump/engine/algorithm.py
    gump/branches/Gump3/pygump/python/gump/model/__init__.py
    gump/branches/Gump3/pygump/python/gump/model/util.py
    gump/branches/Gump3/pygump/python/gump/plugins/builder.py
    gump/branches/Gump3/pygump/python/gump/plugins/logreporter.py
    gump/branches/Gump3/pygump/python/gump/util/__init__.py
    gump/branches/Gump3/pygump/python/gump/util/executor.py
    gump/branches/Gump3/pygump/python/gump/util/mysql.py

Modified: gump/branches/Gump3/gump
URL: http://svn.apache.org/viewcvs/gump/branches/Gump3/gump?rev=168384&r1=168383&r2=168384&view=diff
==============================================================================
--- gump/branches/Gump3/gump (original)
+++ gump/branches/Gump3/gump Thu May  5 11:53:33 2005
@@ -581,7 +581,8 @@
   
   # run pygump
   local current=`pwd`
-  pycompile
+  # disabled for speedier runs
+  # pycompile
 
   if [[ ! -z "$GUMP_CYGWIN" ]]; then
     local old_gump_home=$GUMP_HOME

Modified: gump/branches/Gump3/pygump/gump.log.config
URL: http://svn.apache.org/viewcvs/gump/branches/Gump3/pygump/gump.log.config?rev=168384&r1=168383&r2=168384&view=diff
==============================================================================
--- gump/branches/Gump3/pygump/gump.log.config (original)
+++ gump/branches/Gump3/pygump/gump.log.config Thu May  5 11:53:33 2005
@@ -1,6 +1,6 @@
 # not used atm..
 [loggers]
-keys=root,engine,modeller,walker,plugin,plugin_dynagumper,plugin_logger,util_db
+keys=root,engine,modeller,walker,plugin,plugin_dynagumper,plugin_logger,util_db,util_executor
 
 [handlers]
 keys=stdout,filehandler
@@ -9,60 +9,66 @@
 keys=simple,fileformatter
 
 [logger_root]
-level=DEBUG
+level=WARN
 handlers=stdout,filehandler
 propagate=0
 
 [logger_engine]
-level=DEBUG
+level=WARN
 handlers=stdout,filehandler
 propagate=0
 qualname=engine
 
 [logger_modeller]
-level=DEBUG
+level=WARN
 handlers=stdout,filehandler
 propagate=0
 qualname=modeller
 
 [logger_walker]
-level=INFO
+level=WARN
 handlers=stdout,filehandler
 propagate=0
 qualname=walker
 
 [logger_plugin]
-level=DEBUG
+level=WARN
 handlers=stdout,filehandler
 propagate=0
 qualname=plugin
 
 [logger_util_db]
-level=DEBUG
+level=INFO
 handlers=stdout,filehandler
 propagate=0
 qualname=util.db
 
+[logger_util_executor]
+level=INFO
+handlers=stdout,filehandler
+propagate=0
+qualname=util.executor
+
 [logger_plugin_error-handler]
-level=DEBUG
+level=WARN
 handlers=stdout,filehandler
 propagate=0
 qualname=plugin.error-handler
 
 [logger_plugin_dynagumper]
-level=DEBUG
+level=WARN
 handlers=stdout,filehandler
 propagate=0
 qualname=plugin.dynagumper
 
 [logger_plugin_logger]
-level=DEBUG
+level=INFO
 handlers=stdout,filehandler
 propagate=0
 qualname=plugin.logger
 
 [logger_plugin_builder]
-level=DEBUG
+level=WARN
 handlers=stdout,filehandler
 propagate=0
 qualname=plugin.builder

Copied: gump/branches/Gump3/pygump/gump.log.config.debug (from r168314, gump/branches/Gump3/pygump/gump.log.config)
URL: http://svn.apache.org/viewcvs/gump/branches/Gump3/pygump/gump.log.config.debug?p2=gump/branches/Gump3/pygump/gump.log.config.debug&p1=gump/branches/Gump3/pygump/gump.log.config&r1=168314&r2=168384&rev=168384&view=diff
==============================================================================
--- gump/branches/Gump3/pygump/gump.log.config (original)
+++ gump/branches/Gump3/pygump/gump.log.config.debug Thu May  5 11:53:33 2005
@@ -1,6 +1,6 @@
 # not used atm..
 [loggers]
-keys=root,engine,modeller,walker,plugin,plugin_dynagumper,plugin_logger,util_db
+keys=root,engine,modeller,walker,plugin,plugin_dynagumper,plugin_logger,util_db,util_executor
 
 [handlers]
 keys=stdout,filehandler
@@ -42,6 +42,12 @@
 handlers=stdout,filehandler
 propagate=0
 qualname=util.db
+
+[logger_util_executor]
+level=DEBUG
+handlers=stdout,filehandler
+propagate=0
+qualname=util.executor
 
 [logger_plugin_error-handler]
 level=DEBUG

Modified: gump/branches/Gump3/pygump/main.py
URL: http://svn.apache.org/viewcvs/gump/branches/Gump3/pygump/main.py?rev=168384&r1=168383&r2=168384&view=diff
==============================================================================
--- gump/branches/Gump3/pygump/main.py (original)
+++ gump/branches/Gump3/pygump/main.py Thu May  5 11:53:33 2005
@@ -102,11 +102,11 @@
                       action="store",
                       default=_workspace,
                       help="absolute path to the workspace gump will use")
-    parser.add_option("--no-updates",
+    parser.add_option("--do-updates",
                       action="store_true",
-                      dest="no_updates",
-                      default=True, # Default to NOT. At least during initial development...
-                      help="skip svn updates")
+                      dest="do_update",
+                      default=False, # Default to NOT. At least during initial development...
+                      help="run cvs and svn updates")
     parser.add_option("--databaseserver",
                       action="store",
                       default=_databaseserver,
@@ -127,6 +127,11 @@
                       action="store",
                       default=_databasepassword,
                       help="password gump will use to connect to the database")
+    parser.add_option("--enable-colors",
+                      action="store_true",
+                      dest="enable_colors",
+                      default=False,
+                      help="write log output using ansi color codes")
                       
     return parser
 
@@ -145,7 +150,7 @@
     by one of those.
     """
     
-    def __init__(self, logdir, level=DEBUG, console_level=DEBUG): # Both DEBUG for dev...
+    def __init__(self, logdir, level=INFO, console_level=INFO):
         self.level = level
         self.console_level = console_level
         
@@ -407,6 +412,7 @@
     try:
         if options.debug:
             log.level = DEBUG
+            log.console_level = DEBUG
     
         # print some basic debug info...
         log.debug("Pygump version %s starting..." % (options.version) )
@@ -438,7 +444,7 @@
 
         try:
             # self-update
-            if not options.no_updates:
+            if options.do_update:
                 _svn_update(log, options)
                 
             # finally: fire us up!

Modified: gump/branches/Gump3/pygump/python/gump/config.py
URL: http://svn.apache.org/viewcvs/gump/branches/Gump3/pygump/python/gump/config.py?rev=168384&r1=168383&r2=168384&view=diff
==============================================================================
--- gump/branches/Gump3/pygump/python/gump/config.py (original)
+++ gump/branches/Gump3/pygump/python/gump/config.py Thu May  5 11:53:33 2005
@@ -51,13 +51,12 @@
         config.log_level       = logging.DEBUG
     else:
         config.log_level       = logging.INFO
-
+    
     # TODO: change main.py to do it like this
     config.paths_home      = settings.homedir
     config.paths_work      = settings.workdir
     config.paths_logs      = settings.logdir
     config.paths_workspace = settings.workspace
-    config.do_update       = not settings.no_updates
     config.start_time      = settings.starttimeutc
     
     config.projects        = settings.projects
@@ -117,7 +116,10 @@
         
     from gump.plugins import LoggingPlugin
 
-    
+    reportlog = get_logger(config, "plugin.logger")
+    from gump.plugins.logreporter import DebugLogReporterPlugin
+    plugins.append(DebugLogReporterPlugin(reportlog))
+        
     # by contract, rmdir always needs to go before mkdir!
     from gump.plugins.dirbuilder import RmdirBuilderPlugin
     plugins.append(RmdirBuilderPlugin(config.paths_work))
@@ -138,7 +140,7 @@
     post_process_plugins.append(TimerPlugin("run_end"))
     
     from gump.plugins.dynagumper import Dynagumper
-    dblog = get_logger(config, "util")
+    dblog = get_logger(config, "util.db")
     db = get_db(dblog,config)
     dynagumplog = get_logger(config, "plugin.dynagumper")
     post_process_plugins.append(Dynagumper(db, dynagumplog))
@@ -146,9 +148,12 @@
     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))
+        from gump.plugins.logreporter import OutputLogReporterPlugin
+        post_process_plugins.append(OutputLogReporterPlugin(reportlog))
+
+    from gump.plugins.logreporter import ResultLogReporterPlugin
+    post_process_plugins.append(ResultLogReporterPlugin(reportlog))
+        
     
     # Give us an insight to what we have cooking...
     for plugin in pre_process_plugins: log.debug("Preprocessor : %s " % `plugin`)
@@ -287,14 +292,14 @@
 def get_plugin(config):
     """Provide a Plugin implementation."""
     from gump.engine.algorithm import DumbAlgorithm
-    #from gump.engine.algorithm import MoreEfficientAlgorithm
+    from gump.engine.algorithm import MoreEfficientAlgorithm
     
     (pre_process_plugins, plugins, post_process_plugins) = get_plugins(config)
     error_handler = get_error_handler(config)
     
     return (DumbAlgorithm(pre_process_plugins, error_handler),
-            #MoreEfficientAlgorithm(plugins, error_handler),
-            DumbAlgorithm(plugins, error_handler),
+            MoreEfficientAlgorithm(plugins, error_handler),
+            #DumbAlgorithm(plugins, error_handler),
             DumbAlgorithm(post_process_plugins, error_handler))
 
 #
@@ -306,7 +311,10 @@
 
     # set up logging module
     from logging.config import fileConfig
-    fileConfig('gump.log.config')
+    if config.debug:
+        fileConfig('gump.log.config.debug')
+    else:
+        fileConfig('gump.log.config')
     
     # set up gump.util.executor module
     # this will make Popen log all invocations

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=168384&r1=168383&r2=168384&view=diff
==============================================================================
--- gump/branches/Gump3/pygump/python/gump/engine/__init__.py (original)
+++ gump/branches/Gump3/pygump/python/gump/engine/__init__.py Thu May  5 11:53:33 2005
@@ -45,6 +45,7 @@
 
 from gump.config import *
 from gump.util.io import open_file_or_stream
+from gump.util import ansicolor
 
 _ENGINE_LOGGER_NAME = "engine"
 _MODELLER_LOGGER_NAME = "modeller"
@@ -78,6 +79,10 @@
     # is no if/else branching of any kind, no looping, etc.
     
     # ooh...ah...fancy :-D
+    if settings.enable_colors:
+        from gump.util import ansicolor
+        ansicolor.enable_colors()
+
     _banner(settings.version)
     
     # get engine config
@@ -115,15 +120,13 @@
 
 def _banner(version):
     """Print a fancy ASCII-art gump logo."""
-    print
-    print
-    print "      _____"
-    print "     |   __|_ Apache_ ___"
-    print "     |  |  | | |     | . |"
-    print "     |_____|___|_|_|_|  _|"
-    print "                     |_|     ~ v. " + version + " ~"
-    print
-    print
+    print ansicolor.Bright_Blue
+    print "         _____"
+    print "        |   __|_ " + ansicolor.Red + "Apache" + ansicolor.Bright_Blue + "_ ___"
+    print "        |  |  | | |     | . |"
+    print "        |_____|___|_|_|_|  _|"
+    print "                        |_|     " + ansicolor.Blue + "~ v. " + version + " ~"
+    print ansicolor.Black
 
 
 class EngineError(Exception):

Modified: gump/branches/Gump3/pygump/python/gump/engine/algorithm.py
URL: http://svn.apache.org/viewcvs/gump/branches/Gump3/pygump/python/gump/engine/algorithm.py?rev=168384&r1=168383&r2=168384&view=diff
==============================================================================
--- gump/branches/Gump3/pygump/python/gump/engine/algorithm.py (original)
+++ gump/branches/Gump3/pygump/python/gump/engine/algorithm.py Thu May  5 11:53:33 2005
@@ -34,12 +34,22 @@
 
 import sys
 
+from gump.util import ansicolor
 from gump.model import ModelObject, CvsModule
 from gump.model.util import mark_failure, check_failure, mark_skip, check_skip
 from gump.model.util import mark_whether_module_was_updated
 
 from gump.model.util import UPDATE_TYPE_CHECKOUT, UPDATE_TYPE_UPDATE
 
+class ExceptionInfo(ModelObject):
+    def __init__(self, type, value, traceback):
+        self.type = type
+        self.value = value
+        self.traceback = traceback
+    
+    def __str__(self):
+        return "<%s:%s>" % (self.type, self.value)
+
 class BaseErrorHandler:
     """Base error handler for use with the various algorithms.
     
@@ -73,11 +83,11 @@
 
     def handle(self, visitor, visited_model_object, type, value, traceback):
         """Override this method to be able to swallow exceptions."""
-        self.log.exception("%s threw an exception while visiting %s!" % (visitor, visited_model_object))
+        self.log.exception("%s%s threw an exception while visiting %s!%s" % (ansicolor.Bright_Red,
visitor, visited_model_object, ansicolor.Black))
         if isinstance(visited_model_object, ModelObject):
             if not hasattr(visited_model_object, 'exceptions'):
                 visited_model_object.exceptions = []
-            visited_model_object.exceptions.append( (type, value, traceback) )
+            visited_model_object.exceptions.append( ExceptionInfo(type, value, traceback)
)
 
 class DumbAlgorithm:
     """"Core" algorithm that simply redirects all visit_XXX calls to other plugins."""
@@ -143,7 +153,7 @@
     array named "failure_cause" will be created pointing to the elements that
     "caused" them to fail.
     """
-    def visit_module(self, module):
+    def _visit_module(self, module):
         # run the delegates
         try:
             for visitor in self.list:
@@ -163,11 +173,13 @@
         
         # check for changes
         mark_whether_module_was_updated(module)
-        if not getattr(module, "was_updated", False):
-            for project in module.projects.values():
-                mark_skip(project)
+        #TODO enable
+        #if not getattr(module, "was_updated", False):
+        #    for project in module.projects.values():
+        #        print "Line 170: %s was not updated!" % module.name
+        #        mark_skip(project)
             
-    def visit_project(self, project):
+    def _visit_project(self, project):
         # check for dependencies that failed to build
         for relationship in project.dependencies:
             if check_failure(relationship.dependency):

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?rev=168384&r1=168383&r2=168384&view=diff
==============================================================================
--- gump/branches/Gump3/pygump/python/gump/model/__init__.py (original)
+++ gump/branches/Gump3/pygump/python/gump/model/__init__.py Thu May  5 11:53:33 2005
@@ -26,7 +26,13 @@
 
 class ModelObject:
     """Base object for all gump model elements."""
-    pass
+    def __str__(self):
+        typerep = str(self.__class__).split('.').pop()
+        
+        if hasattr(self, "name"):
+            return "<%s: %s>" % (typerep, self.name)
+        else:
+            return "<%s>" % typerep
 
 
 class Workspace(ModelObject):
@@ -368,6 +374,9 @@
     def add_dependency_info(self, info):
         assert isinstance(info, DependencyInfo)
         self.dependencyInfo.append(info)
+    
+    def __str__(self):
+        return "<Dependency:%s-->%s>" % (self.dependee, self.dependency)
 
 class DependencyInfo(ModelObject):
     """Model information about a particular dependency.
@@ -400,6 +409,10 @@
         self.runtime             = runtime
         self.inherit             = inherit
         self.specific_output_ids = specific_output_ids
+    
+    def __str__(self):
+        return "<DependencyInfo:optional=%s,runtime=%s,inherit=%s,specific_output_ids=%s>"
% \
+               (self.optional, self.runtime, self.inherit, self.specific_output_ids)
 
 class Command(ModelObject):
     """Model a command.
@@ -429,6 +442,9 @@
         assert isinstance(directory, basestring)
         Command.__init__(self, project)
         self.directory = directory
+    
+    def __str__(self):
+        return "<Mkdir:%s>" % self.directory
 
 class Rmdir(Command):
     """Model a delete command.
@@ -446,6 +462,9 @@
         Command.__init__(self, project)
         self.directory = directory
 
+    def __str__(self):
+        return "<Rmdir:%s>" % self.directory
+
 class Script(Command):
     """Command to run a script.
 
@@ -485,6 +504,9 @@
         self.target = target
         self.buildfile = buildfile
 
+    def __str__(self):
+        return "<Ant:%s,target=%s,buildfile=%s>" % (self.name, self.target, self.buildfile)
+
 #TODO: more Commands
 
 OUTPUT_ID_HOME = "homedir"
@@ -504,6 +526,9 @@
         assert isinstance(project, Project)
         self.project = project
         self.id      = id
+    
+    def __str__(self):
+        return "<Output:%s>" % self.id
 
 class Homedir(Output):
     """Model a directory containing stuff that can be used by other projects.
@@ -518,6 +543,9 @@
         assert isinstance(directory, basestring)
         Output.__init__(self, project, OUTPUT_ID_HOME)
         self.directory = directory
+    
+    def __str__(self):
+        return "<Homedir:%s>" % self.directory
 
 class Jar(Output):
     """Model a java archive that can be used by other projects.
@@ -534,6 +562,9 @@
         assert isinstance(name, basestring)
         Output.__init__(self, project, id)
         self.name = name
-        self.add_to_bootclass_path = add_to_bootclass_path      
+        self.add_to_bootclass_path = add_to_bootclass_path
+    
+    def __str__(self):
+        return "<Jar:%s,id=%s,add_to_bootclass_path=%s>" % (self.name, self.id, self.add_to_bootclass_path)
 
 #TODO: more outputs

Modified: gump/branches/Gump3/pygump/python/gump/model/util.py
URL: http://svn.apache.org/viewcvs/gump/branches/Gump3/pygump/python/gump/model/util.py?rev=168384&r1=168383&r2=168384&view=diff
==============================================================================
--- gump/branches/Gump3/pygump/python/gump/model/util.py (original)
+++ gump/branches/Gump3/pygump/python/gump/model/util.py Thu May  5 11:53:33 2005
@@ -69,8 +69,11 @@
     
     Returns only the *first* parent cause, not all of them. Returns
     None if there's no "parent" "cause"."""
+    if isinstance(cause, Dependency):
+        cause = cause.dependency
+
     if not isinstance(cause, ModelObject) \
-       or not len(getattr(model_element, "failure_cause", [])) > 0:
+       or not len(getattr(cause, "failure_cause", [])) > 0:
         return None
     
     return cause.failure_cause[0]
@@ -81,7 +84,12 @@
     Returns an array containing a trace of all the different causes, starting
     with the main cause and ending with the "root" cause."""
     assert isinstance(model_element, ModelObject)
-    assert isinstance(model_element, ModelObject)
+
+    if isinstance(model_element, Dependency):
+        model_element = model_element.dependency
+
+    if not hasattr(model_element, "failure_cause"):
+        return []
     
     cause = model_element.failure_cause[0]
     trace = [cause]
@@ -118,7 +126,7 @@
     """Mark a module as "updated" if it was."""
     # checkout means we did in fact update
     if hasattr(module, "update_type"):
-        if module.update_type == UPDATE_TYPE_CHECKOUT and not module.failed:
+        if module.update_type == UPDATE_TYPE_CHECKOUT and not getattr(module, "failed", False):
             module.was_updated = True
         
     # no checkout, so an update. Might have had no effect. Check.

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=168384&r1=168383&r2=168384&view=diff
==============================================================================
--- gump/branches/Gump3/pygump/python/gump/plugins/builder.py (original)
+++ gump/branches/Gump3/pygump/python/gump/plugins/builder.py Thu May  5 11:53:33 2005
@@ -39,11 +39,8 @@
         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...")
+            self.log.debug("Perform %s on %s" % (command, project))
+            self.method(project, command)
 
 class ScriptBuilderPlugin(BuilderPlugin):
     """Execute all "script" commands for all projects."""

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=168384&r1=168383&r2=168384&view=diff
==============================================================================
--- gump/branches/Gump3/pygump/python/gump/plugins/logreporter.py (original)
+++ gump/branches/Gump3/pygump/python/gump/plugins/logreporter.py Thu May  5 11:53:33 2005
@@ -18,20 +18,43 @@
 __license__   = "http://www.apache.org/licenses/LICENSE-2.0"
 
 from gump.plugins import AbstractPlugin
+from gump.model import Module, Project, Dependency, Command
+from gump.model.util import check_skip, check_failure, get_failure_causes, get_root_cause
+from gump.engine.algorithm import ExceptionInfo
+from gump.util import ansicolor
+
+from StringIO import StringIO
 
 hr = '------------------------------------------------------------------------'
 
-class LogReporterPlugin(AbstractPlugin):
+class DebugLogReporterPlugin(AbstractPlugin):
+    """Outputs debug messages as it visits model elements."""
+    def __init__(self, log):
+        self.log = log
+    
+    def visit_workspace(self, workspace):
+        self.log.info("Processing %s%s%s" % (ansicolor.Bright_Blue, workspace, ansicolor.Black))
+    
+    def visit_repository(self, repository):
+        self.log.info("  Processing %s%s%s" % (ansicolor.Blue, repository, ansicolor.Black))
+    
+    def visit_module(self, module):    
+        self.log.info("    Processing %s%s%s" % (ansicolor.Blue, module, ansicolor.Black))
+    
+    def visit_project(self, project):    
+        self.log.info("      Processing %s%s%s" % (ansicolor.Purple, project, ansicolor.Black))
+            
+class OutputLogReporterPlugin(AbstractPlugin):
     """Outputs all logs set on all log-style model annotations to the log."""
     def __init__(self, log):
         self.log = log
     
     def initialize(self):
         self.log.debug(hr)
-        self.log.debug('  Outputting all log data (a lot)...')
+        self.log.debug('  Outputting all log data (potentially a lot)...')
         self.log.debug(hr)
 
-    def _do_visit(self, object, container=None):
+    def _do_log_printing_visit(self, object, container=None):
         name = getattr(object, "name", "unnamed %s" % type(object))
         if container:
             if hasattr(container, "name"):
@@ -51,22 +74,79 @@
             import traceback
             for entry in object.exceptions:
                 target = StringIO.StringIO()
-                traceback.print_tb(entry[2], file=target)
+                traceback.print_tb(entry.traceback, file=target)
                 trace = target.getvalue()
                 target.close()
-                self.log.error("---%s--exception--%s:%s------:\n%s" % (name, entry[0], entry[1],
trace))
+                self.log.error("---%s--exception--%s:%s------:\n%s" % (name, entry.type,
entry.value, trace))
     
     def visit_workspace(self, workspace):
-        self._do_visit(workspace)
+        self._do_log_printing_visit(workspace)
     
     def visit_module(self, module):    
-        self._do_visit(module)
+        self._do_log_printing_visit(module)
     
     def visit_project(self, project):    
-        self._do_visit(project)
+        self._do_log_printing_visit(project)
         for command in project.commands:
-            self._do_visit(command,project)
+            self._do_log_printing_visit(command,project)
             
     def finalize(self):
-        self.log.debug('  Finished Outputting all log data (a lot)...')
+        self.log.debug('  Finished outputting all log data.')
         self.log.debug(hr)
+
+class ResultLogReporterPlugin(AbstractPlugin):
+    """Outputs information about build results to the logs."""
+    def __init__(self, log):
+        self.log = log
+        self.buffer = StringIO()
+        self.buffer.write('\n')
+    
+    def wr(self,msg):
+        self.buffer.write(msg)
+        self.buffer.write('\n')
+    
+    def initialize(self):
+        self.wr(hr)
+        self.wr('                           %sBUILD RESULTS%s' % (ansicolor.Bright_Blue,
ansicolor.Black))
+        self.wr(hr)
+ 
+    def visit_project(self, project):
+        if check_skip(project):
+            self.wr('%s%s: SKIPPED%s' % (ansicolor.Blue, project, ansicolor.Black))
+            return
+        
+        if not check_failure(project):
+            self.wr('%s%s: OK%s' % (ansicolor.Green, project, ansicolor.Black))
+        else:
+            self.wr('%s%s: FAIL%s' % (ansicolor.Red, project, ansicolor.Black+ansicolor.Black))
+
+            causes = get_failure_causes(project)
+            for cause in causes:
+                if isinstance(cause, ExceptionInfo):
+                    self.wr("    %sMETADATA FAILURE (%s)%s" % (ansicolor.Red, cause, ansicolor.Black))
+                if isinstance(cause, Command):
+                    self.wr("    %sBUILD FAILURE (%s)%s" % (ansicolor.Red, cause, ansicolor.Black))
+                if isinstance(cause, Dependency):
+                    self.wr("    %sPREREQ FAILURE (%s)%s" % (ansicolor.Red, cause.dependency,
ansicolor.Black))
+                if isinstance(cause, Project):
+                    self.wr("    %sPREREQ FAILURE (%s)%s" % (ansicolor.Red, cause, ansicolor.Black))
+                if isinstance(cause, Module):
+                    self.wr("    %sUPDATE FAILURE (%s)%s" % (ansicolor.Red, cause, ansicolor.Black))
+                
+                indent =    "     "
+                for trace_elem in get_root_cause(cause):
+                    real_elem = trace_elem
+                    if isinstance(trace_elem, Dependency):
+                        real_elem = trace_elem.dependency
+                        
+                    if hasattr(real_elem, "name"):
+                        self.wr("%s%s caused by %s%s" % (ansicolor.Grey, indent, real_elem,
ansicolor.Black))
+                        
+                    indent += "  "
+                    
+    def finalize(self):
+        self.wr(hr)
+        
+        self.buffer.flush()
+        self.log.info(self.buffer.getvalue())
+        self.buffer.close()

Modified: gump/branches/Gump3/pygump/python/gump/util/__init__.py
URL: http://svn.apache.org/viewcvs/gump/branches/Gump3/pygump/python/gump/util/__init__.py?rev=168384&r1=168383&r2=168384&view=diff
==============================================================================
--- gump/branches/Gump3/pygump/python/gump/util/__init__.py (original)
+++ gump/branches/Gump3/pygump/python/gump/util/__init__.py Thu May  5 11:53:33 2005
@@ -18,3 +18,45 @@
 
 __copyright__ = "Copyright (c) 2004-2005 The Apache Software Foundation"
 __license__   = "http://www.apache.org/licenses/LICENSE-2.0"
+
+class AnsiColor:
+    Red           =    ''
+    Green         =    ''
+    Yellow        =    ''
+    Blue          =    ''
+    Purple        =    ''
+    Cyan          =    ''
+    
+    Bright_Red    =    ''
+    Bright_Green  =    ''
+    Bright_Yellow =    ''
+    Bright_Blue   =    ''
+    Bright_Purple =    ''
+    Bright_Cyan   =    ''
+    
+    Black         =    ''
+    Grey          =    ''
+    Bright_Grey   =    ''
+    White         =    ''
+
+    def enable_colors(self):
+        self.Red           =    '\033[0;31m'
+        self.Green         =    '\033[0;32m'
+        self.Yellow        =    '\033[0;33m'
+        self.Blue          =    '\033[0;34m'
+        self.Purple        =    '\033[0;35m'
+        self.Cyan          =    '\033[0;36m'
+        
+        self.Bright_Red    =    '\033[1;31m'
+        self.Bright_Green  =    '\033[1;32m'
+        self.Bright_Yellow =    '\033[1;33m'
+        self.Bright_Blue   =    '\033[1;34m'
+        self.Bright_Purple =    '\033[1;35m'
+        self.Bright_Cyan   =    '\033[1;36m'
+        
+        self.Black         =    '\033[0;30m'
+        self.Grey          =    '\033[0;37m'
+        self.Bright_Grey   =    '\033[1;30m'
+        self.White         =    '\033[1;37m'
+
+ansicolor = AnsiColor()

Modified: gump/branches/Gump3/pygump/python/gump/util/executor.py
URL: http://svn.apache.org/viewcvs/gump/branches/Gump3/pygump/python/gump/util/executor.py?rev=168384&r1=168383&r2=168384&view=diff
==============================================================================
--- gump/branches/Gump3/pygump/python/gump/util/executor.py (original)
+++ gump/branches/Gump3/pygump/python/gump/util/executor.py Thu May  5 11:53:33 2005
@@ -39,6 +39,7 @@
 __license__   = "http://www.apache.org/licenses/LICENSE-2.0"
 
 import sys
+from gump.util import ansicolor
 
 # set this to a logging-module-compatible logger to make this module log all
 # the commands it executes
@@ -120,7 +121,7 @@
             
             # a logger can be set for this module to make us log commands
             if _log:
-                _log.debug("Executing command: '%s' in directory '%s'" % (" ".join(args),os.path.abspath(cwd
or os.curdir)))
+                _log.info("Executing command: %s'%s'%s in directory '%s'" % (ansicolor.Blue,
" ".join(args), ansicolor.Black, os.path.abspath(cwd or os.curdir)))
             
             subprocess.Popen.__init__(self, args, bufsize=bufsize, executable=executable,
                      stdin=stdin, stdout=stdout, stderr=stderr,

Modified: gump/branches/Gump3/pygump/python/gump/util/mysql.py
URL: http://svn.apache.org/viewcvs/gump/branches/Gump3/pygump/python/gump/util/mysql.py?rev=168384&r1=168383&r2=168384&view=diff
==============================================================================
--- gump/branches/Gump3/pygump/python/gump/util/mysql.py (original)
+++ gump/branches/Gump3/pygump/python/gump/util/mysql.py Thu May  5 11:53:33 2005
@@ -20,6 +20,7 @@
 __license__   = "http://www.apache.org/licenses/LICENSE-2.0"
 
 import types
+from gump.util import ansicolor
 
 class Database:
     """
@@ -76,14 +77,13 @@
         rows affected and the result set as a tuple of tuples, if there was a
         result set, or None otherwise.
         """
-        self.log.debug("Executing SQL statement: %s" % statement)
         cursor = None
+        affected = 0
         try:
             cursor = self._connection().cursor()
             cursor.execute(statement)
             
             affected = cursor.rowcount
-            self.log.debug("   ...%s rows affected." % affected)
             if statement.lower().startswith("select"):
                 if affected > 0:
                     result = cursor.fetchall()
@@ -91,6 +91,7 @@
                 
             return (affected, None)
         finally:
+            self.log.info("Executed SQL statement: %s%s%s ...%s rows affected." % (ansicolor.Blue,
statement, ansicolor.Black, affected))
             if cursor: cursor.close()
     
     def _connection(self):



Mime
View raw message