tsx_dump_header2doris.py fails on CentOs
Recently I have noticed a problem with the tsx_dump_header2doris.py script on the CentOS systems we use at school. The problem is related to lxml.etree.
I am not 100% sure on what the error is due to but the error message I get is as follows:
Traceback (most recent call last):
File "/nethome/insarlab/insarlab/doris/4.04beta/tsx_dump_header2doris.py", line 9, in ?
from lxml import etree
File "lxml.etree.pyx", line 1, in init lxml.etree (src/lxml/lxml.etree.c:154378)
SystemError: Objects/unicodeobject.c:412: bad argument to internal function
ERROR : [processor.cc[437]]: tsx_dump_header2doris.py: failed with exit code: 256
Caught error of EXCEPTION class!
It is: specific error
I found that making the following change on line 9 from:
from lxml import etree
to:
import xml.etree.cElementTree as etree
The problem goes away. I also changed the shebang line to:
#!/usr/bin/env python
instead of the standard:
#!/usr/bin/python
which allows for using a different python version than the one installed system wide.
Update on 19 Dec 2011: tsx_dump_header2doris.py fails AGAIN on CentOs
On the computers at the University of Alaska, I received the following error message (different from the above problem):
Traceback (most recent call last): File "/home/bosmanoglu/bin/tsx_dump_header2doris.py", line 135, in ? for nodes in inTree.findall(queryListKey): File "etree.pyx", line 1374, in etree._ElementTree.findall File "etree.pyx", line 1081, in etree._Element.findall File "/usr/lib64/python2.4/site-packages/lxml/_elementpath.py", line 193, in findall return _compile(path).findall(element) File "/usr/lib64/python2.4/site-packages/lxml/_elementpath.py", line 171, in _compile p = Path(path) File "/usr/lib64/python2.4/site-packages/lxml/_elementpath.py", line 87, in __init__ raise SyntaxError( SyntaxError: expected path separator ([)
Obviously the default python installed on the servers are not up-to-date and we receive an error message when we try to use the "findall" method. The references below have further information on the problem. To solve the problem I modified the line135 in tsx_dump_header2doris.py with:
try: for nodes in inTree.findall(queryListKey): # for nodes in inTree.findall(queryList[key]): vars()[key].append(nodes.text) except: for nodes in inTree.xpath(queryListKey): vars()[key].append(nodes.text)
Basically, replacing the findall method with xpath solved the problem for this case.
References
|