From a7781537d65919ce1f962f4bf54393e47ccc0814 Mon Sep 17 00:00:00 2001 From: Goffi Date: Sun, 19 Nov 2017 16:38:35 +0100 Subject: [PATCH] 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. --- frontends/src/jp/cmd_debug.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/frontends/src/jp/cmd_debug.py b/frontends/src/jp/cmd_debug.py index db864f98..23cf0f67 100644 --- a/frontends/src/jp/cmd_debug.py +++ b/frontends/src/jp/cmd_debug.py @@ -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')