2 from PyQt4.QtXml import QDomDocument
3 from sface.xmlwidget import XmlWindow, DomModel
7 self.xmlrpcWindow = XmlrpcWindow()
9 def getAndPrint(self, rawOutput):
12 self.xmlrpcWindow.setData(self.xml)
13 if self.xml != "<debug></debug>":
14 # only popup the window if we have something to show
18 self.xmlrpcWindow.show()
19 self.xmlrpcWindow.resize(500, 640)
20 self.xmlrpcWindow.raise_()
21 self.xmlrpcWindow.activateWindow()
23 def store(self, rawOutput):
24 self.rawOutput = rawOutput
27 pttrnAsk = '<methodCall>.*?</methodCall>'
28 pttrnAns = '<methodResponse>.*?</methodResponse>'
29 answers = re.compile(pttrnAsk, re.DOTALL).findall(self.rawOutput)
30 replies = re.compile(pttrnAns, re.DOTALL).findall(self.rawOutput)
32 answers = [ x.replace('\\n','\n') for x in answers ]
33 replies = [ x.replace('\\n','\n').replace("'\nbody: '", '') for x in replies ]
34 replies.reverse() # so that I use pop() as popleft
35 # A well-formed XML document must have one, and only one, top-level element
38 self.xml += ans + replies.pop()
39 self.xml += '</debug>'
42 # statistics: round-trip time, size of the com
45 class XmlrpcWindow(XmlWindow):
46 def __init__(self, parent=None):
47 # super __init__() calls updateView,
48 # which assumes you have some data
49 self.data = '<debug/>'
50 XmlWindow.__init__(self, parent, 'XMLRPC window')
52 def setData(self, XmlrpcCom):
56 XmlWindow.updateView(self)
58 self.document.setContent(self.data)