From 178f4280efc424b048db58f56f5f48a6a2d1e576 Mon Sep 17 00:00:00 2001 From: Jeremie Dimino Date: Tue, 9 Dec 2008 23:37:16 +0100 Subject: [PATCH] [bcfg2/plugins/python] plus besoin d'encoder en base64 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit maintenant l'utf-8 ça marche darcs-hash:20081209223716-af139-f9898825dbbd93a04af46c7e5fa672d6be084cc7.gz --- bcfg2/plugins/Python.py | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/bcfg2/plugins/Python.py b/bcfg2/plugins/Python.py index b7508187..2092bcca 100644 --- a/bcfg2/plugins/Python.py +++ b/bcfg2/plugins/Python.py @@ -135,8 +135,7 @@ class Python(Bcfg2.Server.Plugin.GeneratorPlugin): env["dump"] = lambda incfile: dump(env, incfile) env["info"] = { 'owner': 'root', 'group': 'root', - 'perms': 0644, - 'encoding': 'base64' } + 'perms': 0644 } env.included = set([]) try: include(env, "common") @@ -145,14 +144,20 @@ class Python(Bcfg2.Server.Plugin.GeneratorPlugin): log_traceback(fname, 'exec', e) raise Bcfg2.Server.Plugin.PluginExecutionError info = env["info"] - if info.get('encoding', 'base64') == 'base64': + if info.get('encoding', '') == 'base64': text = binascii.b2a_base64(text) - entry.text = text + # lxml n'accepte que de l'ascii ou de l'unicode + try: + entry.text = text.decode("UTF-8") + except: + # solution de fallback + entry.text = text.decode("ISO8859-15") debug(entry.text) entry.attrib['owner'] = info.get('owner', 'root') entry.attrib['group'] = info.get('group', 'root') entry.attrib['perms'] = oct(info.get('perms', 0644)) - entry.attrib['encoding'] = info.get('encoding', 'base64') + if 'encoding' in info: + entry.attrib['encoding'] = info['encoding'] def HandleEvent(self, event): '''Traitement des événements de FAM'''