libxo question

Mark Saad nonesuch at longcount.org
Fri Dec 28 19:31:21 UTC 2018


All
  I am playing around with procstat and libxo on 12-STABLE from
yesterday . I wanted to get a list of  thread_id's for some processes.
I wrote a quick python script to grab the data but xml output is not
well formed. Here is my sample script , which should work on python
2.7

----8<-----------------------
  1 import subprocess as sp
  2 import os,sys
  3 import pprint as pp
  4 import xml.etree.cElementTree as ET
  5
  6
  7 FNULL = open(os.devnull, 'w')
  8 cmd = "procstat --libxo xml -ta"
  9 p = sp.Popen(cmd, shell=True, stdout=sp.PIPE,stderr=FNULL,
executable="/bin/sh")
 10 text , err = p.communicate()
 11
 12 root = ET.fromstring(text)
 13
 14 pp.pprint(root)
 15
 16 sys.exit(1)
------------>8-----------------------

I am constantly getting this odd issue about the xml being not well formatted

Traceback (most recent call last):
  File "/tmp/test.py", line 12, in <module>
    root = ET.fromstring(text)
  File "<string>", line 124, in XML
cElementTree.ParseError: not well-formed (invalid token): line 1, column 32

Attached is a copy of the xml.   Any guidance would be helpful.


-- 
mark saad | nonesuch at longcount.org


More information about the freebsd-hackers mailing list