2 from PyQt4.QtXml import QDomDocument
3 from sface.xmlwidget import XmlWindow, DomModel
7 self.xmlrpcWindow = XmlrpcWindow()
9 def getAndPrint(self, rawOutput):
10 print "RAW OUTPUT:\n" + rawOutput + "\nEND OF RAW OUT"
13 self.xmlrpcWindow.setData(self.xml)
17 self.xmlrpcWindow.show()
18 self.xmlrpcWindow.resize(500, 640)
19 self.xmlrpcWindow.raise_()
20 self.xmlrpcWindow.activateWindow()
22 def store(self, rawOutput):
23 self.rawOutput = rawOutput
26 pttrnAsk = '<methodCall>.*?</methodCall>'
27 pttrnAns = '<methodResponse>.*?</methodResponse>'
28 answers = re.compile(pttrnAsk, re.DOTALL).findall(self.rawOutput)
29 replies = re.compile(pttrnAns, re.DOTALL).findall(self.rawOutput)
31 answers = map(lambda x: x.replace('\\n','\n'), answers)
32 replies = map(lambda x: x.replace('\\n','\n').replace("'\nbody: '", ''), replies)
33 replies.reverse() # so that I use pop() as popleft
34 # A well-formed XML document must have one, and only one, top-level element
37 self.xml += ans + replies.pop()
38 self.xml += '</debug>'
41 # statistics: round-trip time, size of the com
44 class XmlrpcWindow(XmlWindow):
45 def __init__(self, parent=None):
46 # super __init__() calls updateView,
47 # which assumes you have some data
48 self.data = '<debug/>'
49 XmlWindow.__init__(self, parent, 'XMLRPC window')
51 def setData(self, XmlrpcCom):
55 XmlWindow.updateView(self)
57 self.document.setContent(self.data)