encodage en base64

darcs-hash:20080209030132-af139-279e2d54c973bcef4899128a1f3e22657c60c99b.gz
This commit is contained in:
Jeremie Dimino 2008-02-09 04:01:32 +01:00
parent 74bd5d7b45
commit 9a24822056

View file

@ -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'''