git://git.onelab.eu
/
sface.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
b338d4f
)
remove body: with a double-quote before it, tolerate parsing errors in parseMethodRes...
author
smbaker
<smbaker@fc8clean.lan>
Wed, 7 Sep 2011 02:44:17 +0000
(19:44 -0700)
committer
smbaker
<smbaker@fc8clean.lan>
Wed, 7 Sep 2011 02:44:17 +0000
(19:44 -0700)
sface/xmlrpcwindow.py
patch
|
blob
|
history
diff --git
a/sface/xmlrpcwindow.py
b/sface/xmlrpcwindow.py
index
cc17584
..
81007c0
100644
(file)
--- a/
sface/xmlrpcwindow.py
+++ b/
sface/xmlrpcwindow.py
@@
-20,10
+20,17
@@
class XmlrpcReader():
self.rawOutput = rawOutput
def parseMethodResponse(self, mr):
self.rawOutput = rawOutput
def parseMethodResponse(self, mr):
- tree = etree.fromstring(str(mr))
+ mr = str(mr) # PyQT supplies a QByteArray; make it a string
response = {"kind": "unknown"}
response = {"kind": "unknown"}
+ try:
+ tree = etree.fromstring(mr)
+ except etree.XMLSyntaxError, e:
+ print "failed to parse XML response", str(e)
+ #file("badparse.xml","w").write(mr)
+ return response
+
if tree.tag != "methodResponse" or (len(list(tree))==0):
return response
if tree.tag != "methodResponse" or (len(list(tree))==0):
return response
@@
-62,7
+69,7
@@
class XmlrpcReader():
replies = re.compile(pttrnAns, re.DOTALL).findall(self.rawOutput)
# cleaning
answers = [ x.replace('\\n','\n') for x in answers ]
replies = re.compile(pttrnAns, re.DOTALL).findall(self.rawOutput)
# cleaning
answers = [ x.replace('\\n','\n') for x in answers ]
- replies = [ x.replace('\\n','\n').replace("'\nbody: '", '') for x in replies ]
+ replies = [ x.replace('\\n','\n').replace("'\nbody: '", '')
.replace("\"\nbody: '", '')
for x in replies ]
replies.reverse() # so that I use pop() as popleft
# A well-formed XML document must have one, and only one, top-level element
replies.reverse() # so that I use pop() as popleft
# A well-formed XML document must have one, and only one, top-level element