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/TGenshi.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/TGenshi.py')
-rw-r--r-- | src/lib/Server/Plugins/TGenshi.py | 18 |
1 files changed, 13 insertions, 5 deletions
diff --git a/src/lib/Server/Plugins/TGenshi.py b/src/lib/Server/Plugins/TGenshi.py index 2a12672cc..cd268e967 100644 --- a/src/lib/Server/Plugins/TGenshi.py +++ b/src/lib/Server/Plugins/TGenshi.py @@ -63,16 +63,22 @@ class TemplateFile: try: self.template = loader.load(self.name, cls=self.template_cls, encoding=self.encoding) - except LookupError, lerror: + except LookupError: + lerror = sys.exc_info()[1] logger.error('Genshi lookup error: %s' % lerror) - except TemplateError, terror: + except TemplateError: + terror = sys.exc_info()[1] logger.error('Genshi template error: %s' % terror) - except genshi.input.ParseError, perror: + except genshi.input.ParseError: + perror = sys.exc_info()[1] logger.error('Genshi parse error: %s' % perror) def bind_entry(self, entry, metadata): """Build literal file information.""" fname = entry.get('realname', entry.get('name')) + # py3k compatibility + if sys.hexversion >= 0x03000000: + unicode = str if entry.tag == 'Path': entry.set('type', 'file') try: @@ -107,10 +113,12 @@ class TemplateFile: entry.text = unicode(xmldata, self.encoding) if entry.text == '': entry.set('empty', 'true') - except TemplateError, terror: + except TemplateError: + terror = sys.exc_info()[1] logger.error('Genshi template error: %s' % terror) raise Bcfg2.Server.Plugin.PluginExecutionError - except AttributeError, err: + except AttributeError: + err = sys.exc_info()[1] logger.error('Genshi template loading error: %s' % err) raise Bcfg2.Server.Plugin.PluginExecutionError |