From 9a248220561db5ef55f472f2c7752b5ed1976278 Mon Sep 17 00:00:00 2001 From: Jeremie Dimino Date: Sat, 9 Feb 2008 04:01:32 +0100 Subject: [PATCH] encodage en base64 darcs-hash:20080209030132-af139-279e2d54c973bcef4899128a1f3e22657c60c99b.gz --- bcfg2/plugins/Python.py | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/bcfg2/plugins/Python.py b/bcfg2/plugins/Python.py index 75b68830..0ffa2cde 100644 --- a/bcfg2/plugins/Python.py +++ b/bcfg2/plugins/Python.py @@ -24,7 +24,7 @@ script python''' __all__ = ["Python"] -import logging, lxml.etree, posixpath, re, os, sys +import logging, lxml.etree, posixpath, re, os, sys, binascii from cStringIO import StringIO import Bcfg2.Server.Plugin import traceback @@ -135,18 +135,23 @@ class Python(Bcfg2.Server.Plugin.Plugin): env["dump"] = lambda incfile: dump(env, incfile) env["info"] = { 'owner': 'root', 'group': 'root', - 'perms': 0644 } + 'perms': 0644, + 'encoding': 'base64' } env.included = set([]) try: include(env, "common") - entry.text = pygen.generate(code, env).decode("UTF-8") - debug(entry.text) + text = pygen.generate(code, env) except Exception, e: log_traceback(fname, 'exec', e) raise Bcfg2.Server.Plugin.PluginExecutionError + if env["info"]['encoding'] == 'base64': + text = binascii.b2a_base64(text) + entry.text = text + debug(entry.text) entry.attrib['owner'] = env["info"]['owner'] entry.attrib['group'] = env["info"]['group'] entry.attrib['perms'] = oct(env["info"]['perms']) + entry.attrib['encoding'] = env["info"]['encoding'] def HandleEvent(self, event): '''Traitement des événements de FAM'''