jp (debug/monitor): if data can't be parsed (happen at beginning/end of stream because it's not complete XML), it is printed directly.

This commit is contained in:
Goffi 2017-11-19 16:38:35 +01:00
commit a7781537d6

View file

@ -138,7 +138,16 @@ class Monitor(base.CommandBase):
if whiteping:
self.disp('[WHITESPACE PING]')
else:
self.output(xml_data)
try:
self.output(xml_data)
except Exception:
# initial stream is not valid XML,
# in this case we print directly to data
# FIXME: we should test directly lxml.etree.XMLSyntaxError
# but importing lxml directly here is not clean
# should be wrapped in a custom Exception
self.disp(xml_data)
self.disp(u'')
def start(self):
self.host.bridge.register_signal('xmlLog', self.printXML, 'plugin')