summaryrefslogtreecommitdiffstats
path: root/src/lib/Server/Plugins/Cfg.py
diff options
context:
space:
mode:
authorHolger Weiß <holger@zedat.fu-berlin.de>2011-06-06 16:32:53 +0200
committerSol Jerome <sol.jerome@gmail.com>2011-06-14 12:36:46 -0500
commitb2e9d11b0dca1af6e0ce9a9f21558b35b35f5777 (patch)
tree777d834b7b7a29e9d66904264a8756310444ab7b /src/lib/Server/Plugins/Cfg.py
parentce4a4aa66d30d3c37098b37a8e5fd3fdbabed832 (diff)
downloadbcfg2-b2e9d11b0dca1af6e0ce9a9f21558b35b35f5777.tar.gz
bcfg2-b2e9d11b0dca1af6e0ce9a9f21558b35b35f5777.tar.bz2
bcfg2-b2e9d11b0dca1af6e0ce9a9f21558b35b35f5777.zip
Accept non-ASCII diffs
Currently, client reports don't include diffs of files which aren't US-ASCII encoded. The client transmits such files as Base64 blobs. As we'd like to change that, this commit teaches the server to properly handle non-ASCII diffs.
Diffstat (limited to 'src/lib/Server/Plugins/Cfg.py')
-rw-r--r--src/lib/Server/Plugins/Cfg.py7
1 files changed, 6 insertions, 1 deletions
diff --git a/src/lib/Server/Plugins/Cfg.py b/src/lib/Server/Plugins/Cfg.py
index 5e3cca847..c08e8c4b6 100644
--- a/src/lib/Server/Plugins/Cfg.py
+++ b/src/lib/Server/Plugins/Cfg.py
@@ -197,7 +197,12 @@ class CfgEntrySet(Bcfg2.Server.Plugin.EntrySet):
if os.path.exists("%s.genshi" % name):
logger.error("Cfg: Unable to pull data for genshi types")
raise Bcfg2.Server.Plugin.PluginExecutionError
- open(name, 'w').write(new_entry['text'])
+ try:
+ etext = new_entry['text'].encode(self.encoding)
+ except:
+ logger.error("Cfg: Cannot encode content of %s as %s" % (name, self.encoding))
+ raise Bcfg2.Server.Plugin.PluginExecutionError
+ open(name, 'w').write(etext)
if log:
logger.info("Wrote file %s" % name)
badattr = [attr for attr in ['owner', 'group', 'perms']