summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/lib/Bcfg2/Server/Admin/Bundle.py2
-rw-r--r--src/lib/Bcfg2/Server/Lint/__init__.py6
-rw-r--r--src/lib/Bcfg2/Server/Plugin.py2
-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
-rwxr-xr-xsrc/sbin/bcfg2-build-reports6
-rwxr-xr-xsrc/sbin/bcfg2-crypt2
-rwxr-xr-xsrc/sbin/bcfg2-info3
13 files changed, 29 insertions, 25 deletions
diff --git a/src/lib/Bcfg2/Server/Admin/Bundle.py b/src/lib/Bcfg2/Server/Admin/Bundle.py
index 49e530b15..e5e4eadf3 100644
--- a/src/lib/Bcfg2/Server/Admin/Bundle.py
+++ b/src/lib/Bcfg2/Server/Admin/Bundle.py
@@ -71,8 +71,6 @@ class Bundle(Bcfg2.Server.Admin.MetadataCore):
print('Details for the "%s" bundle:' % \
(bundle_name[int(lineno)].split('.')[0]))
tree = lxml.etree.parse(bundle_list[int(lineno)])
- #Prints bundle content
- #print(lxml.etree.tostring(tree))
names = ['Action', 'Package', 'Path', 'Service']
for name in names:
for node in tree.findall("//" + name):
diff --git a/src/lib/Bcfg2/Server/Lint/__init__.py b/src/lib/Bcfg2/Server/Lint/__init__.py
index 7ee18f924..e3b4c8ea7 100644
--- a/src/lib/Bcfg2/Server/Lint/__init__.py
+++ b/src/lib/Bcfg2/Server/Lint/__init__.py
@@ -90,9 +90,11 @@ class Plugin (object):
if el.text and not keep_text:
el.text = '...'
[el.remove(c) for c in el.iterchildren()]
- xml = lxml.etree.tostring(el, encoding='unicode').strip()
+ xml = lxml.etree.tostring(el,
+ xml_declaration=False).decode("UTF-8").strip()
else:
- xml = lxml.etree.tostring(element, encoding='unicode').strip()
+ xml = lxml.etree.tostring(element,
+ xml_declaration=False).decode("UTF-8").strip()
return " line %s: %s" % (element.sourceline, xml)
diff --git a/src/lib/Bcfg2/Server/Plugin.py b/src/lib/Bcfg2/Server/Plugin.py
index fa2e16c10..97892c42d 100644
--- a/src/lib/Bcfg2/Server/Plugin.py
+++ b/src/lib/Bcfg2/Server/Plugin.py
@@ -266,7 +266,7 @@ class ThreadedStatistics(Statistics, threading.Thread):
try:
pending_data.append((metadata.hostname,
lxml.etree.tostring(data,
- encoding='unicode')))
+ xml_declaration=False).decode("UTF-8")))
except:
err = sys.exc_info()[1]
self.logger.warning("Dropping interaction for %s: %s" %
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
diff --git a/src/sbin/bcfg2-build-reports b/src/sbin/bcfg2-build-reports
index e49446385..318e9de5d 100755
--- a/src/sbin/bcfg2-build-reports
+++ b/src/sbin/bcfg2-build-reports
@@ -110,7 +110,7 @@ def rss(reportxml, delivery, report):
for item in items:
channel.append(item)
- tree = tostring(rssdata, encoding='unicode')
+ tree = tostring(rssdata, xml_declaration=False).decode('UTF-8')
fil.write(tree)
fil.close()
@@ -260,7 +260,7 @@ if __name__ == '__main__':
# Apply XSLT, different ones based on report type, and options
if deliverymechanism == 'null-operator': # Special Cases
- fileout(tostring(ElementTree(procnodereport).getroot(), encoding='unicode'), deliv)
+ fileout(tostring(ElementTree(procnodereport).getroot(), xml_declaration=False).decode('UTF-8'), deliv)
break
transform = delivtype + '-' + deliverymechanism + '.xsl'
@@ -312,7 +312,7 @@ if __name__ == '__main__':
(toastring, socket.getfqdn(), outputstring)
mail(outputstring, c) #call function to send
else:
- outputstring = tostring(stylesheet.apply(ElementTree(procnodereport)).getroot(), encoding='unicode')
+ outputstring = tostring(stylesheet.apply(ElementTree(procnodereport)).getroot(), xml_declaration=False).decode('UTF-8')
if deliverymechanism == 'rss':
rss(outputstring, deliv, reprt)
else: # Must be deliverymechanism == 'www':
diff --git a/src/sbin/bcfg2-crypt b/src/sbin/bcfg2-crypt
index 9da4a25d1..9ce21da82 100755
--- a/src/sbin/bcfg2-crypt
+++ b/src/sbin/bcfg2-crypt
@@ -255,7 +255,7 @@ class PropertiesEncryptor(Encryptor):
while xdata.getparent() != None:
xdata = xdata.getparent()
xdata.set("encryption", "true")
- return lxml.etree.tostring(xdata, encoding='unicode')
+ return lxml.etree.tostring(xdata, xml_declaration=False).decode('UTF-8')
def _get_passphrase(self, chunk):
pname = chunk.get("encrypted") or chunk.get("encryption")
diff --git a/src/sbin/bcfg2-info b/src/sbin/bcfg2-info
index 3f7f33344..7fd00032d 100755
--- a/src/sbin/bcfg2-info
+++ b/src/sbin/bcfg2-info
@@ -395,7 +395,8 @@ class infoCore(cmd.Cmd, Bcfg2.Server.Core.BaseCore):
try:
metadata = self.build_metadata(client)
self.Bind(entry, metadata)
- data = lxml.etree.tostring(entry, encoding="unicode")
+ data = lxml.etree.tostring(entry,
+ xml_declaration=False).decode('UTF-8')
if outfile:
open(outfile, 'w').write(data)
else: