summaryrefslogtreecommitdiffstats
path: root/src/lib/Bcfg2/Server/Plugins
diff options
context:
space:
mode:
authorChris St. Pierre <chris.a.st.pierre@gmail.com>2012-08-22 10:00:38 -0400
committerChris St. Pierre <chris.a.st.pierre@gmail.com>2012-08-22 10:00:38 -0400
commitd59c274547b6aecb3bcbfb99d1b874d403c51bea (patch)
tree7d83406c21f1825a7ec24675f2b6f86123a62da0 /src/lib/Bcfg2/Server/Plugins
parent2c86f67fa234406ee0007a3f77cc1aa9f45ed746 (diff)
downloadbcfg2-d59c274547b6aecb3bcbfb99d1b874d403c51bea.tar.gz
bcfg2-d59c274547b6aecb3bcbfb99d1b874d403c51bea.tar.bz2
bcfg2-d59c274547b6aecb3bcbfb99d1b874d403c51bea.zip
fixed lxml.etree.tostring invocations
Diffstat (limited to 'src/lib/Bcfg2/Server/Plugins')
-rw-r--r--src/lib/Bcfg2/Server/Plugins/Cfg/__init__.py4
-rw-r--r--src/lib/Bcfg2/Server/Plugins/FileProbes.py9
-rw-r--r--src/lib/Bcfg2/Server/Plugins/Metadata.py5
-rw-r--r--src/lib/Bcfg2/Server/Plugins/Packages/__init__.py2
-rw-r--r--src/lib/Bcfg2/Server/Plugins/Probes.py4
-rw-r--r--src/lib/Bcfg2/Server/Plugins/Properties.py7
-rw-r--r--src/lib/Bcfg2/Server/Plugins/Statistics.py2
7 files changed, 18 insertions, 15 deletions
diff --git a/src/lib/Bcfg2/Server/Plugins/Cfg/__init__.py b/src/lib/Bcfg2/Server/Plugins/Cfg/__init__.py
index 5b8dd24d3..4b9403320 100644
--- a/src/lib/Bcfg2/Server/Plugins/Cfg/__init__.py
+++ b/src/lib/Bcfg2/Server/Plugins/Cfg/__init__.py
@@ -386,8 +386,8 @@ class CfgEntrySet(Bcfg2.Server.Plugin.EntrySet):
[infotag.attrib.__setitem__(attr, metadata_updates[attr])
for attr in metadata_updates]
ofile = open(self.path + "/info.xml", "w")
- ofile.write(lxml.etree.tostring(infoxml, encoding='unicode',
- pretty_print=True))
+ ofile.write(lxml.etree.tostring(infoxml, xml_declaration=False,
+ pretty_print=True).decode('UTF-8'))
ofile.close()
self.debug_log("Wrote file %s" % os.path.join(self.path,
"info.xml"),
diff --git a/src/lib/Bcfg2/Server/Plugins/FileProbes.py b/src/lib/Bcfg2/Server/Plugins/FileProbes.py
index a48524ac9..632d586e8 100644
--- a/src/lib/Bcfg2/Server/Plugins/FileProbes.py
+++ b/src/lib/Bcfg2/Server/Plugins/FileProbes.py
@@ -34,7 +34,7 @@ data = lxml.etree.Element("ProbedFileData",
group=grp.getgrgid(stat[5])[0],
perms=oct(stat[0] & 07777))
data.text = b64encode(open(path).read())
-print(lxml.etree.tostring(data, encoding="unicode"))
+print(lxml.etree.tostring(data, xml_declaration=False).decode('UTF-8'))
"""
class FileProbes(Bcfg2.Server.Plugin.Plugin,
@@ -214,9 +214,10 @@ class FileProbes(Bcfg2.Server.Plugin.Plugin,
root = lxml.etree.Element("FileInfo")
root.append(info)
try:
- open(infoxml, "w").write(lxml.etree.tostring(root,
- encoding='unicode',
- pretty_print=True))
+ open(infoxml,
+ "w").write(lxml.etree.tostring(root,
+ xml_declaration=False,
+ pretty_print=True).decode('UTF-8'))
except IOError:
err = sys.exc_info()[1]
self.logger.error("Could not write %s: %s" % (fileloc, err))
diff --git a/src/lib/Bcfg2/Server/Plugins/Metadata.py b/src/lib/Bcfg2/Server/Plugins/Metadata.py
index 8f4f42c96..bc3470273 100644
--- a/src/lib/Bcfg2/Server/Plugins/Metadata.py
+++ b/src/lib/Bcfg2/Server/Plugins/Metadata.py
@@ -151,8 +151,9 @@ class XMLMetadataConfig(Bcfg2.Server.Plugin.XMLFileBacked):
raise Bcfg2.Server.Plugin.MetadataRuntimeError(msg)
# prep data
dataroot = xmltree.getroot()
- newcontents = lxml.etree.tostring(dataroot, pretty_print=True,
- encoding='unicode')
+ newcontents = lxml.etree.tostring(dataroot, xml_declaration=False,
+ pretty_print=True).decode('UTF-8')
+
fd = datafile.fileno()
while locked(fd) == True:
diff --git a/src/lib/Bcfg2/Server/Plugins/Packages/__init__.py b/src/lib/Bcfg2/Server/Plugins/Packages/__init__.py
index 71ae6a038..d3095300a 100644
--- a/src/lib/Bcfg2/Server/Plugins/Packages/__init__.py
+++ b/src/lib/Bcfg2/Server/Plugins/Packages/__init__.py
@@ -178,7 +178,7 @@ class Packages(Bcfg2.Server.Plugin.Plugin,
else:
self.logger.error("Packages: Malformed Package: %s" %
lxml.etree.tostring(pkg,
- encoding='unicode'))
+ xml_declaration=False).decode('UTF-8'))
gpkgs = collection.get_groups(groups)
for group, pkgs in gpkgs.items():
diff --git a/src/lib/Bcfg2/Server/Plugins/Probes.py b/src/lib/Bcfg2/Server/Plugins/Probes.py
index 34b5ab187..cae06b659 100644
--- a/src/lib/Bcfg2/Server/Plugins/Probes.py
+++ b/src/lib/Bcfg2/Server/Plugins/Probes.py
@@ -194,8 +194,8 @@ class Probes(Bcfg2.Server.Plugin.Probing,
lxml.etree.SubElement(cx, "Group", name=group)
try:
datafile = open(os.path.join(self.data, 'probed.xml'), 'w')
- datafile.write(lxml.etree.tostring(top, encoding='unicode',
- pretty_print='true'))
+ datafile.write(lxml.etree.tostring(top, xml_declaration=False,
+ pretty_print='true').decode('UTF-8'))
except IOError:
err = sys.exc_info()[1]
self.logger.error("Failed to write probed.xml: %s" % err)
diff --git a/src/lib/Bcfg2/Server/Plugins/Properties.py b/src/lib/Bcfg2/Server/Plugins/Properties.py
index 3405ad50c..78019933a 100644
--- a/src/lib/Bcfg2/Server/Plugins/Properties.py
+++ b/src/lib/Bcfg2/Server/Plugins/Properties.py
@@ -42,9 +42,10 @@ class PropertyFile(Bcfg2.Server.Plugin.StructFile):
raise Bcfg2.Server.Plugin.PluginExecutionError(msg)
try:
- open(self.name, "wb").write(lxml.etree.tostring(self.xdata,
- encoding='unicode',
- pretty_print=True))
+ open(self.name,
+ "wb").write(lxml.etree.tostring(self.xdata,
+ xml_declaration=False,
+ pretty_print=True).decode('UTF-8'))
return True
except IOError:
err = sys.exc_info()[1]
diff --git a/src/lib/Bcfg2/Server/Plugins/Statistics.py b/src/lib/Bcfg2/Server/Plugins/Statistics.py
index 33b78047a..984efb76c 100644
--- a/src/lib/Bcfg2/Server/Plugins/Statistics.py
+++ b/src/lib/Bcfg2/Server/Plugins/Statistics.py
@@ -35,7 +35,7 @@ class StatisticsStore(object):
self.logger.error("Failed to open %s for writing: %s" % (self.filename + '.new', ioerr))
else:
fout.write(lxml.etree.tostring(self.element,
- encoding='unicode'))
+ xml_declaration=False).decode('UTF-8'))
fout.close()
os.rename(self.filename + '.new', self.filename)
self.dirty = 0