diff options
author | Holger Weiß <holger@zedat.fu-berlin.de> | 2011-06-06 16:32:53 +0200 |
---|---|---|
committer | Holger Weiß <holger@zedat.fu-berlin.de> | 2011-06-06 16:32:53 +0200 |
commit | 3914d14bec1cb7c0f6a600ea8d04ee0e6abc6550 (patch) | |
tree | 777d834b7b7a29e9d66904264a8756310444ab7b /src/lib/Server/Plugins/Cfg.py | |
parent | 701ff48cc9561ce88e80c1de5a19f8d6cda790bb (diff) | |
download | bcfg2-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/Cfg.py')
-rw-r--r-- | src/lib/Server/Plugins/Cfg.py | 7 |
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'] |