From 36d356091d9703459149a6fc6d0840492dc31454 Mon Sep 17 00:00:00 2001 From: Narayan Desai Date: Sun, 26 Aug 2007 19:17:28 +0000 Subject: Implement better error reporting for TCheetah Cheetah template errors now display: NotFound: cannot find 'hostn' while searching for 'self.metadata.hostn' Failed to template /bcfg2.conf git-svn-id: https://svn.mcs.anl.gov/repos/bcfg/trunk/bcfg2@3645 ce84e21b-d406-0410-9b95-82705330c041 --- src/lib/Server/Plugins/TCheetah.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/lib/Server/Plugins/TCheetah.py b/src/lib/Server/Plugins/TCheetah.py index 3eb41e834..ec31a66b9 100644 --- a/src/lib/Server/Plugins/TCheetah.py +++ b/src/lib/Server/Plugins/TCheetah.py @@ -1,7 +1,8 @@ '''This module implements a templating generator based on Cheetah''' __revision__ = '$Revision$' -import logging, lxml.etree, posixpath, re, Cheetah.Parser, Cheetah.Template +import logging, lxml.etree, posixpath, traceback, re, sys +import Cheetah.Template, Cheetah.Parser import Bcfg2.Server.Plugin logger = logging.getLogger('Bcfg2.Plugins.TCheetah') @@ -56,7 +57,11 @@ class TemplateFile: try: entry.text = str(self.template) except: + (a,b,c) = sys.exc_info() + msg = traceback.format_exception(a, b, c, limit=2)[-1][:-1] + logger.error(msg) logger.error("Failed to template %s" % entry.get('name')) + del a, b, c raise Bcfg2.Server.Plugin.PluginExecutionError if hasattr(self, 'infoxml'): mdata = {} -- cgit v1.2.3-1-g7c22