From: Ondrej Lichtner <olichtne(a)redhat.com>
This patch works around some issues with the old version of lxml library
available in RHEL6.
The first change is parsing the xslt document from a URL needs to
happen first otherwise the parser is unable to access URLs - know bug in
the old lxml library that is fixed in newer versions.
The second is that the tostring() method didn't support a doctype
parameter in older versions so instead we add the DOCTYPE manually.
Signed-off-by: Ondrej Lichtner <olichtne(a)redhat.com>
---
lnst/Controller/NetTestResultSerializer.py | 10 ++++------
1 file changed, 4 insertions(+), 6 deletions(-)
diff --git a/lnst/Controller/NetTestResultSerializer.py
b/lnst/Controller/NetTestResultSerializer.py
index bf3da1e..62d4e43 100644
--- a/lnst/Controller/NetTestResultSerializer.py
+++ b/lnst/Controller/NetTestResultSerializer.py
@@ -18,7 +18,6 @@ from lnst.Common.NetTestCommand import str_command
from lnst.Common.Colours import decorate_string, decorate_with_preset
from lnst.Common.Config import lnst_config
from lxml import etree
-from lxml import html as lxml_h
def serialize_obj(obj, dom, el, upper_name="unnamed"):
if isinstance(obj, dict):
@@ -279,14 +278,13 @@ class NetTestResultSerializer:
return doc.toprettyxml()
def get_result_html(self):
+ xslt_url = lnst_config.get_option("environment", "xslt_url")
+ xslt = etree.parse(xslt_url)
+
xml = self._generate_xml().toprettyxml()
etree_xml = etree.fromstring(xml)
- xslt_url = lnst_config.get_option("environment", "xslt_url")
- xslt = etree.parse(xslt_url)
transform = etree.XSLT(xslt)
transformed_xml = transform(etree_xml)
- html = lxml_h.fromstring(etree.tostring(transformed_xml))
- return lxml_h.tostring(html, pretty_print=True,
- doctype="<!DOCTYPE html>")
+ return "<!DOCTYPE html>\n" + str(transformed_xml)
--
1.9.3
Show replies by date