diff options
author | Sol Jerome <sol.jerome@gmail.com> | 2011-04-26 15:18:04 -0500 |
---|---|---|
committer | Sol Jerome <sol.jerome@gmail.com> | 2011-04-26 15:18:04 -0500 |
commit | bef2d0c73eb0b3fd071f616aa43a945ae2d103b7 (patch) | |
tree | 6b7442075da3d88d649ac9cbe82d6007558e7c8f /src/lib/Server/Plugins/TCheetah.py | |
parent | 944df5470f9d30717baccf7b716fd4847b31da27 (diff) | |
download | bcfg2-bef2d0c73eb0b3fd071f616aa43a945ae2d103b7.tar.gz bcfg2-bef2d0c73eb0b3fd071f616aa43a945ae2d103b7.tar.bz2 bcfg2-bef2d0c73eb0b3fd071f616aa43a945ae2d103b7.zip |
Plugins: Add full PY3K compatibility
Signed-off-by: Sol Jerome <sol.jerome@gmail.com>
Diffstat (limited to 'src/lib/Server/Plugins/TCheetah.py')
-rw-r--r-- | src/lib/Server/Plugins/TCheetah.py | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/src/lib/Server/Plugins/TCheetah.py b/src/lib/Server/Plugins/TCheetah.py index d40f4baf3..151cc6543 100644 --- a/src/lib/Server/Plugins/TCheetah.py +++ b/src/lib/Server/Plugins/TCheetah.py @@ -36,7 +36,8 @@ class TemplateFile: self.template = Cheetah.Template.Template(open(self.name).read(), compilerSettings=s, searchList=self.searchlist) - except Cheetah.Parser.ParseError, perror: + except Cheetah.Parser.ParseError: + perror = sys.exc_info()[1] logger.error("Cheetah parse error for file %s" % (self.name)) logger.error(perror.report()) @@ -52,11 +53,14 @@ class TemplateFile: if entry.tag == 'Path': entry.set('type', 'file') try: + # py3k compatibility + if sys.hexversion >= 0x03000000: + unicode = str if type(self.template) == unicode: entry.text = self.template else: if entry.get('encoding') == 'base64': - # take care of case where file needs base64 encoding + # take care of case where file needs base64 encoding entry.text = binascii.b2a_base64(self.template) else: entry.text = unicode(str(self.template), self.encoding) |