summaryrefslogtreecommitdiffstats
path: root/src/lib/Server/Plugins
diff options
context:
space:
mode:
authorHolger Weiß <holger@zedat.fu-berlin.de>2011-06-06 16:32:53 +0200
committerHolger Weiß <holger@zedat.fu-berlin.de>2011-06-06 16:32:53 +0200
commit3914d14bec1cb7c0f6a600ea8d04ee0e6abc6550 (patch)
tree777d834b7b7a29e9d66904264a8756310444ab7b /src/lib/Server/Plugins
parent701ff48cc9561ce88e80c1de5a19f8d6cda790bb (diff)
downloadbcfg2-3914d14bec1cb7c0f6a600ea8d04ee0e6abc6550.tar.gz
bcfg2-3914d14bec1cb7c0f6a600ea8d04ee0e6abc6550.tar.bz2
bcfg2-3914d14bec1cb7c0f6a600ea8d04ee0e6abc6550.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')
-rw-r--r--src/lib/Server/Plugins/Cfg.py7
-rw-r--r--src/lib/Server/Plugins/DBStats.py1
2 files changed, 7 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']
diff --git a/src/lib/Server/Plugins/DBStats.py b/src/lib/Server/Plugins/DBStats.py
index 5ef1920e1..103fb7353 100644
--- a/src/lib/Server/Plugins/DBStats.py
+++ b/src/lib/Server/Plugins/DBStats.py
@@ -55,6 +55,7 @@ class DBStats(Bcfg2.Server.Plugin.Plugin,
try:
Bcfg2.Server.Reports.importscript.load_stats(self.core.metadata.clients_xml.xdata,
container,
+ self.core.encoding,
0,
logger,
True,