gump-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From leosim...@apache.org
Subject svn commit: r123736 - in gump/branches/Dec04MajorCleanup/pygump: . python/gump/actor python/gump/core python/gump/core/build python/gump/core/language python/gump/core/model python/gump/core/run python/gump/core/update python/gump/engine python/gump/model
Date Thu, 30 Dec 2004 22:40:09 GMT
Author: leosimons
Date: Thu Dec 30 14:40:09 2004
New Revision: 123736

URL: http://svn.apache.org/viewcvs?view=rev&rev=123736
Log:
* Get rid of yet more stuff. Yet more stuff??? Yeah, to make sure that 'gump pycompile' can
do all its imports. Will need to add a lot back in later.
* start on a new, normalized, unambiguous, passive model with no intelligence whatsoever
* start on a drastically simplified core engine
Added:
   gump/branches/Dec04MajorCleanup/pygump/python/gump/engine/
   gump/branches/Dec04MajorCleanup/pygump/python/gump/engine/__init__.py
      - copied, changed from r123720, gump/branches/Dec04MajorCleanup/pygump/python/gump/__init__.py
   gump/branches/Dec04MajorCleanup/pygump/python/gump/model/
Removed:
   gump/branches/Dec04MajorCleanup/pygump/python/gump/actor/notifier.py
   gump/branches/Dec04MajorCleanup/pygump/python/gump/core/build/
   gump/branches/Dec04MajorCleanup/pygump/python/gump/core/config.py
   gump/branches/Dec04MajorCleanup/pygump/python/gump/core/language/
   gump/branches/Dec04MajorCleanup/pygump/python/gump/core/model/builder.py
   gump/branches/Dec04MajorCleanup/pygump/python/gump/core/model/depend.py
   gump/branches/Dec04MajorCleanup/pygump/python/gump/core/model/misc.py
   gump/branches/Dec04MajorCleanup/pygump/python/gump/core/model/module.py
   gump/branches/Dec04MajorCleanup/pygump/python/gump/core/model/object.py
   gump/branches/Dec04MajorCleanup/pygump/python/gump/core/model/profile.py
   gump/branches/Dec04MajorCleanup/pygump/python/gump/core/model/project.py
   gump/branches/Dec04MajorCleanup/pygump/python/gump/core/model/propagation.py
   gump/branches/Dec04MajorCleanup/pygump/python/gump/core/model/property.py
   gump/branches/Dec04MajorCleanup/pygump/python/gump/core/model/repository.py
   gump/branches/Dec04MajorCleanup/pygump/python/gump/core/model/server.py
   gump/branches/Dec04MajorCleanup/pygump/python/gump/core/model/state.py
   gump/branches/Dec04MajorCleanup/pygump/python/gump/core/model/stats.py
   gump/branches/Dec04MajorCleanup/pygump/python/gump/core/model/tracker.py
   gump/branches/Dec04MajorCleanup/pygump/python/gump/core/model/workspace.py
   gump/branches/Dec04MajorCleanup/pygump/python/gump/core/run/
   gump/branches/Dec04MajorCleanup/pygump/python/gump/core/update/
Modified:
   gump/branches/Dec04MajorCleanup/pygump/main.py
   gump/branches/Dec04MajorCleanup/pygump/python/gump/actor/dynagumper.py
   gump/branches/Dec04MajorCleanup/pygump/python/gump/core/model/__init__.py

Modified: gump/branches/Dec04MajorCleanup/pygump/main.py
Url: http://svn.apache.org/viewcvs/gump/branches/Dec04MajorCleanup/pygump/main.py?view=diff&rev=123736&p1=gump/branches/Dec04MajorCleanup/pygump/main.py&r1=123735&p2=gump/branches/Dec04MajorCleanup/pygump/main.py&r2=123736
==============================================================================
--- gump/branches/Dec04MajorCleanup/pygump/main.py	(original)
+++ gump/branches/Dec04MajorCleanup/pygump/main.py	Thu Dec 30 14:40:09 2004
@@ -220,7 +220,7 @@
 
 def send_error_email(Exception,details,options,log):
     """
-    TODO. Send an error report by e-mail.
+    Send an error report by e-mail.
     """
     if options.mailserver and options.mailport and options.mailto and options.mailfrom:
         subject="Fatal error during pygump run [%s: %s]" % (options.hostname, options.name)
@@ -273,9 +273,10 @@
 
 def start_engine(log,options):
     """
-    TODO. Fire up the core pygump engine to do its thing.
+    Fire up the core pygump engine to do its thing.
     """
-    pass
+    import gump.engine
+    engine.main(options)
 
 def main():
     """

Modified: gump/branches/Dec04MajorCleanup/pygump/python/gump/actor/dynagumper.py
Url: http://svn.apache.org/viewcvs/gump/branches/Dec04MajorCleanup/pygump/python/gump/actor/dynagumper.py?view=diff&rev=123736&p1=gump/branches/Dec04MajorCleanup/pygump/python/gump/actor/dynagumper.py&r1=123735&p2=gump/branches/Dec04MajorCleanup/pygump/python/gump/actor/dynagumper.py&r2=123736
==============================================================================
--- gump/branches/Dec04MajorCleanup/pygump/python/gump/actor/dynagumper.py	(original)
+++ gump/branches/Dec04MajorCleanup/pygump/python/gump/actor/dynagumper.py	Thu Dec 30 14:40:09
2004
@@ -19,10 +19,11 @@
 
 import platform
 
-from gump.core.run.gumprun import *
-import gump.core.run.actor
+# comment out stuff to make it import without errors...
+#from gump.core.run.gumprun import *
+#import gump.core.run.actor
 
-class Dynagumper(gump.core.run.actor.AbstractRunActor):
+class Dynagumper: #(gump.core.run.actor.AbstractRunActor):
     """
     Populate the DynaGump run metadata database.
     """
@@ -36,7 +37,7 @@
         Optional argument: log, instance of logging.logger or similar.
         Will use log from gump.logging if not provided.
         """
-        gump.core.run.actor.AbstractRunActor.__init__(self,run)    
+        #gump.core.run.actor.AbstractRunActor.__init__(self,run)    
         self.db = db
         
         if not log: from gump import log

Deleted: /gump/branches/Dec04MajorCleanup/pygump/python/gump/actor/notifier.py
Url: http://svn.apache.org/viewcvs/gump/branches/Dec04MajorCleanup/pygump/python/gump/actor/notifier.py?view=auto&rev=123735
==============================================================================

Deleted: /gump/branches/Dec04MajorCleanup/pygump/python/gump/core/config.py
Url: http://svn.apache.org/viewcvs/gump/branches/Dec04MajorCleanup/pygump/python/gump/core/config.py?view=auto&rev=123735
==============================================================================

Modified: gump/branches/Dec04MajorCleanup/pygump/python/gump/core/model/__init__.py
Url: http://svn.apache.org/viewcvs/gump/branches/Dec04MajorCleanup/pygump/python/gump/core/model/__init__.py?view=diff&rev=123736&p1=gump/branches/Dec04MajorCleanup/pygump/python/gump/core/model/__init__.py&r1=123735&p2=gump/branches/Dec04MajorCleanup/pygump/python/gump/core/model/__init__.py&r2=123736
==============================================================================
--- gump/branches/Dec04MajorCleanup/pygump/python/gump/core/model/__init__.py	(original)
+++ gump/branches/Dec04MajorCleanup/pygump/python/gump/core/model/__init__.py	Thu Dec 30 14:40:09
2004
@@ -1,6 +1,6 @@
-#!/usr/bin/python
+#!/usr/bin/env python
 
-# Copyright 2003-2004 The Apache Software Foundation
+# 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.
@@ -14,33 +14,314 @@
 # See the License for the specific language governing permissions and
 # limitations under the License.
 
-"""
-  Gump XML model.
+__copyright__ = "Copyright (c) 2004-2005 The Apache Software Foundation"
+__license__   = "http://www.apache.org/licenses/LICENSE-2.0"
 
-  It contains a sax dispatcher tool, a dependency
-  walker, and an object model (GOM) which is built from an xmlfile using
-  the sax dispatcher.
-
-  The idea is that a subclass of GumpModelObject is used for each of the various
-  xml tags which can appear in a gump profile, with a saxdispatcher
-  generating a tree of GumpModelObject objects from the profile, dynamically
-  merging as it finds href references.
-
-  You can then use the dependencies() method to get an ordered, flat vector
-  of the projects in the profile.
-
-  Then there's some basic procedures to work with the GOM, like load().
-
-  For basic usage patterns, look at the gump.view module or the gump.core.build
-  module.
-"""
-
-###############################################################################
-# Initialize
-###############################################################################
-
-# tell Python what modules make up the gump.core.model package
-__all__ = ["misc","state", \
-    "object","project","module","workspace","repository", \
-    "builder","profile",]
+class ModelError(Exception):
+    pass
 
+class ModelObject:
+    """
+    Base object for all gump model elements.
+    """
+    pass
+
+class Workspace(ModelObject):
+    """
+    Model gump workspace and profile. Has the following properties:
+        
+        - name     -- per-host unique identifier
+        - repositories -- dictionary of contained repositories
+        - servers  -- list of servers gump knows about (TODO: remove)
+        - trackers -- list of issue trackers gump knows about (TODO: remove)
+    """
+    def __init__(self, name):
+        self.name = name
+        self.repositories={}
+
+        self.servers={}
+        self.trackers={}
+    
+    def add_repository(self, repository):
+        self.repositories[repository.name] = repository
+    
+    def add_server(self, server):
+        self.servers[server.name] = server
+    
+    def add_tracker(self, tracker):
+        self.trackers[tracker.name] = tracker
+
+class Repository(ModelObject):
+    """
+    Model a source control repository. Has the following properties:
+        
+        - workspace -- reference to the containing workspace
+        - name      -- per-run unique identifier
+        - title     -- human-readable identifier
+        - home_page -- web address of associated project or organisation
+        - cvsweb    -- web address for online viewing of this repository
+        - redistributable -- flag indicating whether this project can be
+                       redistributed under AL-compatible terms
+        - modules   -- dictionary of contained modules
+    """
+    def __init__(self,
+                 workspace,
+                 name,
+                 title = None,
+                 home_page = None,
+                 cvsweb = None,
+                 redistributable = False):
+        self.workspace       = workspace
+        self.name            = name
+        self.title           = title
+        self.home_page       = home_page
+        self.cvsweb          = cvsweb
+        self.redistributable = redistributable
+
+        self.modules={}
+
+    def add_module(self, module):
+        self.modules[module.name] = module
+    
+
+CVS_METHOD_PSERVER="pserver"
+
+class CvsRepository(Repository):
+    """
+    Model a CVS repository. Has the following properties:
+        
+        - all of the properties a Repository has
+        - hostname -- the address of the cvs server
+        TODO: - port
+        - path     -- the path to the cvs repository on the server
+        - method   -- the cvs connection method to use
+        - user     -- the cvs user to login as
+        - password -- the cvs password to login with
+    """
+    def __init__(self,
+                 workspace,
+                 name,
+                 hostname,
+                 path,
+                 title = None,
+                 home_page = None,
+                 cvsweb = None,
+                 redistributable = False,
+                 method = CVS_METHOD_PSERVER,
+                 user = None,
+                 password = None):
+        Repository.__init__(self, workspace, name, title, home_page, cvsweb, redistributable)
+        self.hostname = hostname
+        self.path     = path,
+        self.method   = method,
+        self.user     = user,
+        self.password = password
+
+class SvnRepository(Repository):
+    """
+    Model a subversion repository. Has the following properties:
+        
+        - all of the properties a Repository has
+        - url      -- the address of the svn repository
+        TODO: - user     -- the cvs user to login as
+        TODO: - password -- the cvs password to login with
+    """
+    def __init__(self,
+                 workspace,
+                 name,
+                 url,
+                 title = None,
+                 home_page = None,
+                 cvsweb = None,
+                 redistributable = False,
+                 user = None,
+                 password = None):
+        Repository.__init__(self, workspace, name, title, home_page, cvsweb, redistributable)
+        self.url      = url
+        self.user     = user,
+        self.password = password
+
+class Module(ModelObject):
+    """
+    Model a module within a source control repository. Has the following
+    properties:
+        
+        - repository  -- the containing repository
+        - name        -- per-run unique identifier
+        - directory   -- base directory within the containing repository
+                         for this module
+        - url         -- web address of associated project
+        - description -- human-readable description
+    """
+    def __init__(self,
+                 repository,
+                 name,
+                 directory = None,
+                 url = None,
+                 description = None):
+        """
+        Create the module.
+        """
+        self.repository  = repository
+        self.name        = name
+        self.directory   = directory
+        self.url         = url
+        self.description = description
+        
+        self.projects = {}
+
+    def add_project(self, project):
+        self.projects[project.name] = project
+
+class Project(ModelObject):
+    """
+    Model a "project", as far as gump is concerned this is the primary
+    "unit of work", something to "build". Projects reside within modules. Has
+    the following properties:
+        
+        - module       -- the containing module
+        - name         -- per-run unique identifier
+        - dependencies -- list of Dependency instances describing what other
+                          projects this project depends upon
+        - dependees    -- list of Dependency instances describing what other
+                          projects depend on this project
+        - commands     -- ordered list of Commands instances that need to be
+                          executed to build this project
+        - outputs      -- list of Output instances describing what results a
+                          build of this project results in
+    """
+    def __init__(self, module, name):
+        self.module = module
+        self.name   = name
+        
+        self.dependencies=[]
+        self.dependees=[]
+        self.commands=[]
+        self.outputs=[]
+    
+    def add_dependency(self, dependency):
+        self.dependencies.append(dependency)
+        dependency.dependee.add_dependee(dependency)
+    
+    def add_dependee(self, dependee):
+        self.dependees.append(dependee)
+    
+    def add_command(self, command):
+        self.commands.append(command)
+    
+    def add_output(self, output):
+        self.outputs.append(command)
+
+DEPENDENCY_INHERIT_NONE          = "none"
+DEPENDENCY_INHERIT_RUNTIME       = "runtime"
+DEPENDENCY_INHERIT_ALL           = "all"
+DEPENDENCY_INHERIT_HARD          = "hard"
+
+# "copy-outputs" inheritance means that all the outputs of the dependee should
+# be made into outputs of the dependency. For java projects this is known as
+# "jars" inheritance.
+DEPENDENCY_INHERIT_COPY_OUTPUTS  = "copy-outputs"
+DEPENDENCY_INHERIT_JARS          = DEPENDENCY_INHERIT_COPY_OUTPUTS
+
+class Dependency(ModelObject):
+    """
+    A dependency is a directional link between two projects, where one
+    project (the dependency) depends on another project (the dependee).
+    Has the following properties:
+        
+        - dependency -- the project that is depending on the other project
+        - dependee   -- the project that is being depended on by 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
+                        dependency at runtime or just for building
+    """
+    def __init__(dependency,
+                 dependee,
+                 optional = False,
+                 runtime  = False,
+                 inherit  = DEPENDENCY_INHERIT_NONE,
+                 specific_output_id = None):
+        self.dependency         = dependency
+        self.dependee           = dependee
+        self.optional           = optional
+        self.runtime            = runtime
+        self.inherit            = inherit
+        self.specific_output_id = specific_output_id
+
+class Command(ModelObject):
+    """
+    A command is something to do as part of a build. Has the following
+    properties:
+        
+        - project -- the containing project
+    """
+    def __init__(self, project):
+        self.project = project
+    pass
+
+class Mkdir(Command):
+    """
+    Create a directory. The directory is specified relative to the source
+    directory of the project. Has the following properties:
+        
+        - all the properties a Command has
+        - directory -- the directory to create
+    """
+    def __init__(self, project, directory):
+        Command.__init__(self, project)
+        self.directory = directory
+
+class Rmdir(Command):
+    """
+    Delete a directory. The directory is specified relative to the source
+    directory of the project. Has the following properties:
+        
+        - all the properties a Command has
+        - directory -- the directory to delete
+    """
+    def __init__(self, project, directory):
+        Command.__init__(self, project)
+        self.directory = directory
+
+class Script(Command):
+    """
+    Run a script. Has the following properties:
+        
+        - all the properties a Command has
+        - name -- the name of the script to run
+        - args -- a list of arguments to the command
+    """
+    def __init__(self, project, name, args=[]):
+        Command.__init__(self, project)
+        self.name = name
+        self.args = args
+
+OUTPUT_ID_HOME = "homedir"
+
+class Output(ModelObject):
+    """
+    Something a successful project build will yield. Outputs can be given an
+    id to be able to distinguish multiple outputs from another. Has the
+    following properties:
+        
+        - project -- the containing project
+        - id      -- a per-project unique identifier
+    """
+    def __init__(self, project, id = None):
+        self.project = project
+        self.id      = id
+
+class Homedir(Output):
+    """
+    A directory containing stuff that can be used by other projects. Has the
+    following properties:
+
+        - all the properties an Output has
+        - directory -- the directory that should be exported as this project
+                       its homedirectory
+    """
+    def __init__(self, project, id, directory):
+        Output.__init__(self, project, id)
+        self.directory = directory

Deleted: /gump/branches/Dec04MajorCleanup/pygump/python/gump/core/model/builder.py
Url: http://svn.apache.org/viewcvs/gump/branches/Dec04MajorCleanup/pygump/python/gump/core/model/builder.py?view=auto&rev=123735
==============================================================================

Deleted: /gump/branches/Dec04MajorCleanup/pygump/python/gump/core/model/depend.py
Url: http://svn.apache.org/viewcvs/gump/branches/Dec04MajorCleanup/pygump/python/gump/core/model/depend.py?view=auto&rev=123735
==============================================================================

Deleted: /gump/branches/Dec04MajorCleanup/pygump/python/gump/core/model/misc.py
Url: http://svn.apache.org/viewcvs/gump/branches/Dec04MajorCleanup/pygump/python/gump/core/model/misc.py?view=auto&rev=123735
==============================================================================

Deleted: /gump/branches/Dec04MajorCleanup/pygump/python/gump/core/model/module.py
Url: http://svn.apache.org/viewcvs/gump/branches/Dec04MajorCleanup/pygump/python/gump/core/model/module.py?view=auto&rev=123735
==============================================================================

Deleted: /gump/branches/Dec04MajorCleanup/pygump/python/gump/core/model/object.py
Url: http://svn.apache.org/viewcvs/gump/branches/Dec04MajorCleanup/pygump/python/gump/core/model/object.py?view=auto&rev=123735
==============================================================================

Deleted: /gump/branches/Dec04MajorCleanup/pygump/python/gump/core/model/profile.py
Url: http://svn.apache.org/viewcvs/gump/branches/Dec04MajorCleanup/pygump/python/gump/core/model/profile.py?view=auto&rev=123735
==============================================================================

Deleted: /gump/branches/Dec04MajorCleanup/pygump/python/gump/core/model/project.py
Url: http://svn.apache.org/viewcvs/gump/branches/Dec04MajorCleanup/pygump/python/gump/core/model/project.py?view=auto&rev=123735
==============================================================================

Deleted: /gump/branches/Dec04MajorCleanup/pygump/python/gump/core/model/propagation.py
Url: http://svn.apache.org/viewcvs/gump/branches/Dec04MajorCleanup/pygump/python/gump/core/model/propagation.py?view=auto&rev=123735
==============================================================================

Deleted: /gump/branches/Dec04MajorCleanup/pygump/python/gump/core/model/property.py
Url: http://svn.apache.org/viewcvs/gump/branches/Dec04MajorCleanup/pygump/python/gump/core/model/property.py?view=auto&rev=123735
==============================================================================

Deleted: /gump/branches/Dec04MajorCleanup/pygump/python/gump/core/model/repository.py
Url: http://svn.apache.org/viewcvs/gump/branches/Dec04MajorCleanup/pygump/python/gump/core/model/repository.py?view=auto&rev=123735
==============================================================================

Deleted: /gump/branches/Dec04MajorCleanup/pygump/python/gump/core/model/server.py
Url: http://svn.apache.org/viewcvs/gump/branches/Dec04MajorCleanup/pygump/python/gump/core/model/server.py?view=auto&rev=123735
==============================================================================

Deleted: /gump/branches/Dec04MajorCleanup/pygump/python/gump/core/model/state.py
Url: http://svn.apache.org/viewcvs/gump/branches/Dec04MajorCleanup/pygump/python/gump/core/model/state.py?view=auto&rev=123735
==============================================================================

Deleted: /gump/branches/Dec04MajorCleanup/pygump/python/gump/core/model/stats.py
Url: http://svn.apache.org/viewcvs/gump/branches/Dec04MajorCleanup/pygump/python/gump/core/model/stats.py?view=auto&rev=123735
==============================================================================

Deleted: /gump/branches/Dec04MajorCleanup/pygump/python/gump/core/model/tracker.py
Url: http://svn.apache.org/viewcvs/gump/branches/Dec04MajorCleanup/pygump/python/gump/core/model/tracker.py?view=auto&rev=123735
==============================================================================

Deleted: /gump/branches/Dec04MajorCleanup/pygump/python/gump/core/model/workspace.py
Url: http://svn.apache.org/viewcvs/gump/branches/Dec04MajorCleanup/pygump/python/gump/core/model/workspace.py?view=auto&rev=123735
==============================================================================

Copied: gump/branches/Dec04MajorCleanup/pygump/python/gump/engine/__init__.py (from r123720,
gump/branches/Dec04MajorCleanup/pygump/python/gump/__init__.py)
Url: http://svn.apache.org/viewcvs/gump/branches/Dec04MajorCleanup/pygump/python/gump/engine/__init__.py?view=diff&rev=123736&p1=gump/branches/Dec04MajorCleanup/pygump/python/gump/__init__.py&r1=123720&p2=gump/branches/Dec04MajorCleanup/pygump/python/gump/engine/__init__.py&r2=123736
==============================================================================
--- gump/branches/Dec04MajorCleanup/pygump/python/gump/__init__.py	(original)
+++ gump/branches/Dec04MajorCleanup/pygump/python/gump/engine/__init__.py	Thu Dec 30 14:40:09
2004
@@ -1,6 +1,6 @@
 #!/usr/bin/env python
 
-# Copyright 2003-2004 The Apache Software Foundation
+# 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.
@@ -14,18 +14,183 @@
 # See the License for the specific language governing permissions and
 # limitations under the License.
 
-__copyright__ = "Copyright (c) 2003-2004 Apache Software Foundation"
+__copyright__ = "Copyright (c) 2004-2005 The Apache Software Foundation"
 __license__   = "http://www.apache.org/licenses/LICENSE-2.0"
 
-import os
-
 import logging
-import logging.config
-
-_gumphome = os.environ["GUMP_HOME"]
+import os
 
-# configure the logger
-logging.config.fileConfig(_gumphome + "/pygump/gump.log.config")
+from xml import dom
+from xml.dom import minidom
 
-# base gump logger
-log = logging.getLogger("root")
+from gump.engine.workspace import WorkspaceLoader, WorkspaceObjectifier
+       
+def main(settings):
+    """
+    Controls the big pygump beast. This function is called from the main.main()
+    method once the environment has been analyzed, parsed, fully set
+    up, and checked for correctness. In other words, once the beastie is
+    ready to roll.
+    
+    It creates an Engine and starts it.
+    
+    Arguments:
+      - settings -- everything the engine needs to know about the environment.
+    """
+    
+    # get engine config
+    config = get_settings(settings)
+    
+    # get engine dependencies
+    log = get_logger(config.log_level, "engine")
+    db  = get_db(config)
+    vfsdir = os.path.join(config.workdir, "vfs-cache" )
+    if not os.path.isdir(vfsdir):
+        os.mkdir(vfsdir);
+    vfs = get_vfs(config.homedir, vfsdir)
+    workspace_loader = get_workspace_loader(vfs, log)
+    workspace_objectifier = get_workspace_objectifier()
+    
+    # create engine
+    engine = Engine(config, log, db, workspace_loader)
+    
+    # run it
+    engine.initialize()
+    engine.run()
+    engine.dispose()
+
+###
+### FACTORY METHODS
+###
+
+def get_config(settings):
+    """
+    Convert the settings object (the Values retrieved from the OptionsParser)
+    into something more specific. The reason we put this function and the Config
+    class in between is that we can change gump internals while keeping the CLI
+    interface the same more easily, with the integration point being isolated to
+    this method and the Config class definition.
+    """
+    config = Config()
+    
+    if settings.debug:
+        config.log_level       = logging.DEBUG
+    else:
+        config.log_level       = logging.INFO
+
+    config.hostname        = settings.hostname
+    config.projects        = settings.projects
+    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
+    
+    config.mail_server     = settings.mailserver
+    config.mail_server_port = settings.mailport
+    config.mail_to         = settings.mailto
+    config.mail_from       = settings.mailfrom
+    
+    # TODO: set defaults in main.py instead
+    config.database_server = "localhost"
+    if hasattr(settings,"databaseserver"): config.database_server = settings.databaseserver
+    config.database_port   = 3306
+    if hasattr(settings,"databaseport"): config.database_port = settings.databaseport
+    config.database_name   = "gump"
+    if hasattr(settings,"databasename"): config.database_name = settings.databasename
+    config.database_user   = "gump"
+    if hasattr(settings,"databaseuser"): config.database_user = settings.databaseuser
+    config.database_password   = "gump"
+    if hasattr(settings,"databasepassword"): config.database_password = settings.databasepassword
+
+def get_logger(level, name):
+    log = logging.Logger(name)
+    log.setLevel(level)
+    return logger
+
+def get_db(config):
+    from gump.util.database import Database
+    db = Database(config) #TODO!
+    return db
+
+def get_vfs(filesystem_root, cache_dir):
+    return VFS(filesystem_root, cache_dir)
+
+def get_workspace_loader(vfs, log):
+    return WorkspaceLoader(vfs, log)
+
+def get_workspace_objectifier():
+    return WorkspaceObjectifier
+
+###
+### Classes
+###
+
+class Config:
+    def __getattr__(self,name):
+        """
+        Some config values are calculated at runtime from other values
+        if they're not especially set.
+        """
+        if name == 'debug':
+            return self.loglevel >= logging.DEBUG
+        if name == 'paths_pygump':
+            return os.path.jion(self.paths_home, "pygump")
+        if name == 'paths_metadata':
+            return os.path.join(self.paths_home, "metadata")
+        if name == 'do_mail':
+            return self.mail_server and self.mail_server_port and self.mail_to and self.mail_from
+        
+        # unknown, raise error
+        raise AttributeError, name
+
+class Engine:
+    """
+    This is the core of the pygump application.
+    """
+    
+    def __init__(self, config, log, db, workspace_loader, workspace_objectifier):
+        """
+        Store all config and dependencies as properties.
+        """
+        self.config = config
+        self.log = log
+        self.workspace_loader = workspace_loader
+        self.workspace_objectifier = workspace_objectifier
+        self.db = db
+    
+    def initialize(self):
+        """
+        Perform pre-run initialization.
+        """
+        pass
+    
+    def run(self):
+        """
+        Perform a run.
+        """
+        try:
+            # 1) merge workspace into big DOM tree
+            (dom, dropped_nodes) = self.workspace_loader.get_workspace_tree(self.config.path_workspace)
+            # 2) convert that DOM tree into python objects
+            workspace = self.workspace_objectifier.get_workspace(dom)
+            # 3) store those objects in the database
+            self.store_workspace(self.workspace) #TODO
+            # 4) determine the tasks to perform
+            self.tasks = self.create_ordered_tasklist() #TODO
+            
+            # 5) now make the workers perform those tasks
+            self.create_workers() #TODO
+            self.start_workers() #TODO
+            self.wait_for_workers() #TODO
+        except:
+            self.log.exception("Fatal error during run!")
+    
+    def dispose(self):
+        """
+        End a run.
+        """
+        pass

Mime
View raw message