From a6781fdff0e1ede8ed3bed5a2886127c9a42b408 Mon Sep 17 00:00:00 2001 From: Narayan Desai Date: Fri, 15 Sep 2006 02:11:37 +0000 Subject: Implement useful error handling for template parse failures git-svn-id: https://svn.mcs.anl.gov/repos/bcfg/trunk/bcfg2@2254 ce84e21b-d406-0410-9b95-82705330c041 --- src/lib/Server/Plugins/TCheetah.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/lib/Server/Plugins/TCheetah.py b/src/lib/Server/Plugins/TCheetah.py index 7032e09fa..0ef453a9e 100644 --- a/src/lib/Server/Plugins/TCheetah.py +++ b/src/lib/Server/Plugins/TCheetah.py @@ -1,7 +1,7 @@ '''This module implements a templating generator based on Cheetah''' __revision__ = '$Revision$' -import logging, lxml.etree, posixpath, re, Cheetah.Template +import logging, lxml.etree, posixpath, re, Cheetah.Parser, Cheetah.Template import Bcfg2.Server.Plugin logger = logging.getLogger('Bcfg2.Plugins.TCheetah') @@ -19,8 +19,12 @@ class TemplateFile: def HandleEvent(self, event): '''Handle all fs events for this template''' if event.filename == 'template': - self.template = Cheetah.Template.Template(open(self.name).read()) - self.template.properties = self.properties.properties + try: + self.template = Cheetah.Template.Template(open(self.name).read()) + self.template.properties = self.properties.properties + except Cheetah.Parser.ParseError, perror: + logger.error("Cheetah parse error for file %s" % (self.name)) + logger.error(perror.report()) elif event.filename == 'info': for line in open(self.name[:-8] + '/info').readlines(): match = info.match(line) -- cgit v1.2.3-1-g7c22