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)
16 self.xmlrpcWindow.show()
17 self.xmlrpcWindow.resize(500, 640)
18 self.xmlrpcWindow.raise_()
19 self.xmlrpcWindow.activateWindow()
21 def store(self, rawOutput):
22 self.rawOutput = rawOutput
25 pttrnAsk = '<methodCall>.*?</methodCall>'
26 pttrnAns = '<methodResponse>.*?</methodResponse>'
27 answers = re.compile(pttrnAsk, re.DOTALL).findall(self.rawOutput)
28 replies = re.compile(pttrnAns, re.DOTALL).findall(self.rawOutput)
30 answers = map(lambda x: x.replace('\\n','\n'), answers)
31 replies = map(lambda x: x.replace('\\n','\n').replace("'\nbody: '", ''), replies)
32 replies.reverse() # so that I use pop() as popleft
33 # A well-formed XML document must have one, and only one, top-level element
36 self.xml += ans + replies.pop()
37 self.xml += '</debug>'
40 # statistics: round-trip time, size of the com
43 class XmlrpcWindow(XmlWindow):
44 def __init__(self, parent=None):
45 # super __init__() calls updateView,
46 # which assumes you have some data
47 self.data = '<debug/>'
48 XmlWindow.__init__(self, parent, 'XMLRPC window')
50 def setData(self, XmlrpcCom):
54 XmlWindow.updateView(self)
56 self.document.setContent(self.data)