gump-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From leosim...@apache.org
Subject svn commit: r123751 - in gump/branches/Dec04MajorCleanup/pygump: . python/gump/engine
Date Thu, 30 Dec 2004 23:40:12 GMT
Author: leosimons
Date: Thu Dec 30 15:40:08 2004
New Revision: 123751

URL: http://svn.apache.org/viewcvs?view=rev&rev=123751
Log:
make things fail properly
Modified:
   gump/branches/Dec04MajorCleanup/pygump/main.py
   gump/branches/Dec04MajorCleanup/pygump/python/gump/engine/__init__.py
   gump/branches/Dec04MajorCleanup/pygump/python/gump/engine/vfs.py
   gump/branches/Dec04MajorCleanup/pygump/python/gump/engine/workspace.py

Modified: gump/branches/Dec04MajorCleanup/pygump/main.py
Url: http://svn.apache.org/viewcvs/gump/branches/Dec04MajorCleanup/pygump/main.py?view=diff&rev=123751&p1=gump/branches/Dec04MajorCleanup/pygump/main.py&r1=123750&p2=gump/branches/Dec04MajorCleanup/pygump/main.py&r2=123751
==============================================================================
--- gump/branches/Dec04MajorCleanup/pygump/main.py	(original)
+++ gump/branches/Dec04MajorCleanup/pygump/main.py	Thu Dec 30 15:40:08 2004
@@ -110,6 +110,18 @@
             print message,
         if self.level >= ERROR:
             self.target.write(message);
+    
+    def exception(self, msg):
+        info = sys.exc_info()
+        self.error(msg)
+
+        import traceback
+        from StringIO import StringIO
+        buf = StringIO()
+        traceback.print_exception( info[0], info[1], info[2], file=buf)
+        self.error(buf.getvalue())
+        buf.close()
+
 
     def critical(self, msg):
         message = 'CRITICAL: %s\n' % (msg)
@@ -255,7 +267,7 @@
         except Exception, details:
             if not log.target:
                 log.target = open(log.filename, 'w', 0)
-            log.error("Exception occurred reading log file: %s: %s" % (Exception, details))
+            log.exception("Exception occurred reading log file")
             if logfile: logfile.close()
             if logbody == "":
                 logbody = "ERROR: unable to read logfile!"
@@ -275,7 +287,7 @@
     """
     Fire up the core pygump engine to do its thing.
     """
-    import gump.engine
+    from gump import engine
     engine.main(options)
 
 def main():
@@ -313,7 +325,7 @@
     
     # and some basic settings calculated from those
     _logdir        = os.path.join(_workdir, "log")
-    _workspace     = os.path.join(_homedir, "pygump", "metadata", "%s.xml" % (_hostname))
+    _workspace     = os.path.join(_homedir, "metadata", "%s.xml" % (_hostname))
     
     # get basic settings from commandline arguments
     from optparse import OptionParser
@@ -393,14 +405,13 @@
             # finally: fire us up!
             start_engine(log, options)
             log.info("Run completed!")
-            raise GumpConfigError, "Sample error"
         except Exception, details:
             # this is not good. Send e-mail to the admin, complaining rather loudly.
-            log.error("an uncaught exception occurred: %s: %s" % (Exception, details))
+            log.exception("an uncaught exception occurred")
             try:
                 send_error_email(Exception, details, options, log)
             except Exception, details:
-                log.error("Unable to send e-mail to administrator: %s: %s" % (Exception,
details))
+                log.exception("Unable to send e-mail to administrator")
                 pass
             
             sys.exit(1)

Modified: gump/branches/Dec04MajorCleanup/pygump/python/gump/engine/__init__.py
Url: http://svn.apache.org/viewcvs/gump/branches/Dec04MajorCleanup/pygump/python/gump/engine/__init__.py?view=diff&rev=123751&p1=gump/branches/Dec04MajorCleanup/pygump/python/gump/engine/__init__.py&r1=123750&p2=gump/branches/Dec04MajorCleanup/pygump/python/gump/engine/__init__.py&r2=123751
==============================================================================
--- gump/branches/Dec04MajorCleanup/pygump/python/gump/engine/__init__.py	(original)
+++ gump/branches/Dec04MajorCleanup/pygump/python/gump/engine/__init__.py	Thu Dec 30 15:40:08
2004
@@ -24,6 +24,7 @@
 from xml.dom import minidom
 
 from gump.engine.workspace import WorkspaceLoader, WorkspaceObjectifier
+from gump.engine.vfs import VFS
        
 def main(settings):
     """
@@ -39,20 +40,20 @@
     """
     
     # get engine config
-    config = get_settings(settings)
+    config = get_config(settings)
     
     # get engine dependencies
     log = get_logger(config.log_level, "engine")
     db  = get_db(config)
-    vfsdir = os.path.join(config.workdir, "vfs-cache" )
+    vfsdir = os.path.join(config.paths_work, "vfs-cache" )
     if not os.path.isdir(vfsdir):
         os.mkdir(vfsdir);
-    vfs = get_vfs(config.homedir, vfsdir)
+    vfs = get_vfs(config.paths_home, vfsdir)
     workspace_loader = get_workspace_loader(vfs, log)
     workspace_objectifier = get_workspace_objectifier()
     
     # create engine
-    engine = Engine(config, log, db, workspace_loader)
+    engine = Engine(config, log, db, workspace_loader, workspace_objectifier)
     
     # run it
     engine.initialize()
@@ -105,14 +106,17 @@
     if hasattr(settings,"databaseuser"): config.database_user = settings.databaseuser
     config.database_password   = "gump"
     if hasattr(settings,"databasepassword"): config.database_password = settings.databasepassword
+    
+    return config
 
 def get_logger(level, name):
-    log = logging.Logger(name)
+    logging.basicConfig()
+    log = logging.getLogger(name)
     log.setLevel(level)
-    return logger
+    return log
 
 def get_db(config):
-    from gump.util.database import Database
+    from gump.util.mysql import Database
     db = Database(config) #TODO!
     return db
 
@@ -158,9 +162,9 @@
         """
         self.config = config
         self.log = log
+        self.db = db
         self.workspace_loader = workspace_loader
         self.workspace_objectifier = workspace_objectifier
-        self.db = db
     
     def initialize(self):
         """
@@ -174,7 +178,7 @@
         """
         try:
             # 1) merge workspace into big DOM tree
-            (dom, dropped_nodes) = self.workspace_loader.get_workspace_tree(self.config.path_workspace)
+            (dom, dropped_nodes) = self.workspace_loader.get_workspace_tree(self.config.paths_workspace)
             # 2) convert that DOM tree into python objects
             workspace = self.workspace_objectifier.get_workspace(dom)
             # 3) store those objects in the database

Modified: gump/branches/Dec04MajorCleanup/pygump/python/gump/engine/vfs.py
Url: http://svn.apache.org/viewcvs/gump/branches/Dec04MajorCleanup/pygump/python/gump/engine/vfs.py?view=diff&rev=123751&p1=gump/branches/Dec04MajorCleanup/pygump/python/gump/engine/vfs.py&r1=123750&p2=gump/branches/Dec04MajorCleanup/pygump/python/gump/engine/vfs.py&r2=123751
==============================================================================
--- gump/branches/Dec04MajorCleanup/pygump/python/gump/engine/vfs.py	(original)
+++ gump/branches/Dec04MajorCleanup/pygump/python/gump/engine/vfs.py	Thu Dec 30 15:40:08 2004
@@ -22,7 +22,7 @@
     Provides homogenized access to local files, as well as files residing
     on remote servers (HTTP or FTP or ...).
     """
-    def __init__(filesystem_root = None, cachedir = None):
+    def __init__(self, filesystem_root = None, cachedir = None):
         self.filesystem_root = filesystem_root
         self.cachedir = cachedir
     

Modified: gump/branches/Dec04MajorCleanup/pygump/python/gump/engine/workspace.py
Url: http://svn.apache.org/viewcvs/gump/branches/Dec04MajorCleanup/pygump/python/gump/engine/workspace.py?view=diff&rev=123751&p1=gump/branches/Dec04MajorCleanup/pygump/python/gump/engine/workspace.py&r1=123750&p2=gump/branches/Dec04MajorCleanup/pygump/python/gump/engine/workspace.py&r2=123751
==============================================================================
--- gump/branches/Dec04MajorCleanup/pygump/python/gump/engine/workspace.py	(original)
+++ gump/branches/Dec04MajorCleanup/pygump/python/gump/engine/workspace.py	Thu Dec 30 15:40:08
2004
@@ -32,7 +32,7 @@
     """
     Parses XML, resolves HREFs, creates a big DOM tree.
     """
-    def __init__(self,vfs,log,workspace):
+    def __init__(self,vfs,log):
         self.log = log
         self.vfs = vfs
 
@@ -52,7 +52,7 @@
         return (dom, dropped_nodes)
     
     def _resolve_hrefs_in_workspace(self, dom, dropped_nodes):
-        self._resolve_hrefs_in_children(self, dom, dropped_nodes)
+        self._resolve_hrefs_in_children(dom, dropped_nodes)
     
     def _resolve_hrefs_in_children(self, node, dropped_nodes):
         """
@@ -61,9 +61,9 @@
         The resolution is done in a resolve-then-recurse manner, so the end
         result is a dom tree without hrefs.
         """
-        for child in node.documentElement.childNodes:
+        for child in node.childNodes:
             # retrieve the referenced document and merge it in
-            if child.nodeType == node.Node.ELEMENT_NODE:
+            if child.nodeType == dom.Node.ELEMENT_NODE:
                 if child.hasAttribute('href'):
                     if not 'url' == child.tagName: # make exception for the <url/>
tag, which
                                                    # documents an url for a project
@@ -138,13 +138,13 @@
 
         if not parent:
             # TODO provide more info
-            raise WorkspaceError, "Unresolvable HREF found outside a <project/> or
<module/>."
+            raise WorkspaceError, "Unresolvable HREF found outside a <project/> or
<module/>: %s." % (node)
         
         # remove that project or module from its parent
         node_to_remove_element_from = parent.parentNode
         if not node_to_remove_element_from:
             # TODO provide more info
-            raise WorkspaceError, "Rogue <project/> or <module/> (without a parent)."
+            raise WorkspaceError, "Rogue <project/> or <module/> (without a parent):
%s." % (parent)
         node_to_remove_element_from.removeChild(parent)
         
         # but save it off for error reporting

Mime
View raw message