Return-Path: Mailing-List: contact gump-help@jakarta.apache.org; run by ezmlm Delivered-To: mailing list gump@jakarta.apache.org Received: (qmail 44631 invoked by uid 500); 4 May 2003 08:49:08 -0000 Received: (qmail 44628 invoked from network); 4 May 2003 08:49:08 -0000 Received: from icarus.apache.org (208.185.179.13) by daedalus.apache.org with SMTP; 4 May 2003 08:49:08 -0000 Received: (qmail 91911 invoked by uid 1464); 4 May 2003 08:49:07 -0000 Date: 4 May 2003 08:49:07 -0000 Message-ID: <20030504084907.91910.qmail@icarus.apache.org> From: nicolaken@apache.org To: jakarta-gump-cvs@apache.org Subject: cvs commit: jakarta-gump/python/gump model.py X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N nicolaken 2003/05/04 01:49:07 Modified: python/gump model.py Log: Added logging. Do not fail if it cannot resolve a property, but warn instead. This is a hack to be able to load the model even with errors, so I can run a "check.py" module on it and output what is missing. Revision Changes Path 1.7 +56 -28 jakarta-gump/python/gump/model.py Index: model.py =================================================================== RCS file: /home/cvs/jakarta-gump/python/gump/model.py,v retrieving revision 1.6 retrieving revision 1.7 diff -u -r1.6 -r1.7 --- model.py 2 May 2003 17:15:20 -0000 1.6 +++ model.py 4 May 2003 08:49:06 -0000 1.7 @@ -58,6 +58,28 @@ # information on the Apache Software Foundation, please see # . +import os,types,logging + +from gump import GumpBase, Named, Single, Multiple +from gump.conf import dir, default + + +############################################################################### +# Initialize +############################################################################### + +# use own logging + +# init logging +logging.basicConfig() + +# base gump logger +log = logging.getLogger(__name__) + +#set verbosity to show all messages of severity >= default.logLevel +log.setLevel(default.logLevel) + + ############################################################################### # Gump Object Model # @@ -65,9 +87,6 @@ # above, allowing the actual model to be rather simple and compact. ############################################################################### -import os,types -from gump import GumpBase, Named, Single, Multiple - class Workspace(GumpBase): """Represents a element.""" @@ -318,32 +337,41 @@ # provide default elements when not defined in xml def complete(self,project): if self.reference=='home': - self.value=Project.list[self.project].home + try: + self.value=Project.list[self.project].home + except: + log.warn( "Cannot resolve homedir of " + self.project + " for " + project.name) elif self.reference=='srcdir': - module=Project.list[self.project].module - self.value=Module.list[module].srcdir - + try: + module=Project.list[self.project].module + self.value=Module.list[module].srcdir + except: + log.warn( "Cannot resolve srcdir of " + self.project + " for " + project.name) + elif self.reference=='jarpath': - target=Project.list[self.project] - if self.id: - for jar in target.jar: - if jar.id==self.id: - self.value=jar.path - break + try: + target=Project.list[self.project] + if self.id: + for jar in target.jar: + if jar.id==self.id: + self.value=jar.path + break + else: + raise str(("jar with id %s was not found in project %s " + "referenced by %s") % (self.id, target.name, project.name)) + elif len(target.jar)==1: + self.value=target.jar[0].path + elif len(target.jar)>1: + raise str(("Multiple jars defined by project %s referenced by %s; " + + "an id attribute is required to select the one you want") % + (target.name, project.name)) else: - raise str(("jar with id %s was not found in project %s " - "referenced by %s") % (self.id, target.name, project.name)) - elif len(target.jar)==1: - self.value=target.jar[0].path - elif len(target.jar)>1: - raise str(("Multiple jars defined by project %s referenced by %s; " + - "an id attribute is required to select the one you want") % - (target.name, project.name)) - else: - raise str("Project %s referenced by %s defines no jars as output" % - (target.name, project.name)) - + raise str("Project %s referenced by %s defines no jars as output" % + (target.name, project.name)) + + except: + log.warn( "Cannot resolve jarpath of " + self.project + " for " + project.name) # TODO: set up the below elements with defaults using complete()