From 83cd22ac2b9194db84593acea0cb056cbe73e02c Mon Sep 17 00:00:00 2001 From: "John W. O'Brien" Date: Sun, 8 May 2016 16:09:09 -0400 Subject: [PATCH] Use lxml for Python 2.6 compatibility The version of ElementTree that ships with Python 2.6 only has support for "path/path" style XPath syntax, and cannot handle paths of the form "path/path[attr='val']/path", and will crash with a traceback similar to: Traceback (most recent call last): File "", line 1, in File "/opt/local/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/xml/etree/ElementTree.py", line 355, in findall return ElementPath.findall(self, path) File "/opt/local/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/xml/etree/ElementPath.py", line 198, in findall return _compile(path).findall(element) File "/opt/local/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/xml/etree/ElementPath.py", line 176, in _compile p = Path(path) File "/opt/local/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/xml/etree/ElementPath.py", line 93, in __init__ "expected path separator (%s)" % (op or tag) SyntaxError: expected path separator ([) For example, RHEL6 ships with Python 2.6, and lxml 2.2.3. --- bind9stats.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bind9stats.py b/bind9stats.py index b5ed3cb..1a23132 100755 --- a/bind9stats.py +++ b/bind9stats.py @@ -13,7 +13,7 @@ """ import os, sys -import xml.etree.ElementTree as et +from lxml import etree as et try: from urllib2 import urlopen # for Python 2 except ImportError: