[bcfg2/plugins/python] plus besoin d'encoder en base64
maintenant l'utf-8 ça marche darcs-hash:20081209223716-af139-f9898825dbbd93a04af46c7e5fa672d6be084cc7.gz
This commit is contained in:
parent
8ee7ed82a8
commit
178f4280ef
1 changed files with 10 additions and 5 deletions
|
@ -135,8 +135,7 @@ class Python(Bcfg2.Server.Plugin.GeneratorPlugin):
|
||||||
env["dump"] = lambda incfile: dump(env, incfile)
|
env["dump"] = lambda incfile: dump(env, incfile)
|
||||||
env["info"] = { 'owner': 'root',
|
env["info"] = { 'owner': 'root',
|
||||||
'group': 'root',
|
'group': 'root',
|
||||||
'perms': 0644,
|
'perms': 0644 }
|
||||||
'encoding': 'base64' }
|
|
||||||
env.included = set([])
|
env.included = set([])
|
||||||
try:
|
try:
|
||||||
include(env, "common")
|
include(env, "common")
|
||||||
|
@ -145,14 +144,20 @@ class Python(Bcfg2.Server.Plugin.GeneratorPlugin):
|
||||||
log_traceback(fname, 'exec', e)
|
log_traceback(fname, 'exec', e)
|
||||||
raise Bcfg2.Server.Plugin.PluginExecutionError
|
raise Bcfg2.Server.Plugin.PluginExecutionError
|
||||||
info = env["info"]
|
info = env["info"]
|
||||||
if info.get('encoding', 'base64') == 'base64':
|
if info.get('encoding', '') == 'base64':
|
||||||
text = binascii.b2a_base64(text)
|
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)
|
debug(entry.text)
|
||||||
entry.attrib['owner'] = info.get('owner', 'root')
|
entry.attrib['owner'] = info.get('owner', 'root')
|
||||||
entry.attrib['group'] = info.get('group', 'root')
|
entry.attrib['group'] = info.get('group', 'root')
|
||||||
entry.attrib['perms'] = oct(info.get('perms', 0644))
|
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):
|
def HandleEvent(self, event):
|
||||||
'''Traitement des événements de FAM'''
|
'''Traitement des événements de FAM'''
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue