]> code.delx.au - pymsnt/blobdiff - src/legacy/msn/msn.py
Support for Twisted 2.0.1 and 2.1.0
[pymsnt] / src / legacy / msn / msn.py
index d3da1e474145fecd93271d47a7ab4647acdf45b8..835106cebd0caaa409c07e126c6fbcc5559ba581 100644 (file)
@@ -520,13 +520,18 @@ class MSNObject:
         e = parseText(s, True)
         if not e:
             return # Parse failed
-        self.creator = e.getAttribute("Creator")
-        self.size = int(e.getAttribute("Size"))
-        self.type = int(e.getAttribute("Type"))
-        self.location = e.getAttribute("Location")
-        self.friendly = e.getAttribute("Friendly")
-        self.sha1d = e.getAttribute("SHA1D")
-        self.text = s
+        try:
+            self.creator = e.getAttribute("Creator")
+            self.size = int(e.getAttribute("Size"))
+            self.type = int(e.getAttribute("Type"))
+            self.location = e.getAttribute("Location")
+            self.friendly = e.getAttribute("Friendly")
+            self.sha1d = e.getAttribute("SHA1D")
+            self.text = s
+        except TypeError:
+            self.setNull()
+        except ValueError:
+            self.setNull()
 
 
 class MSNContact:
@@ -1130,7 +1135,7 @@ class NotificationClient(MSNEventBase):
         msnContact.status = params[1]
         msnContact.screenName = unquote(params[3])
         if len(params) > 4: msnContact.caps = int(params[4])
-        if len(params) > 5:
+        if len(params) > 5 and params[5] != "0":
             self.handleAvatarHelper(msnContact, params[5])
         else:
             self.handleAvatarGoneHelper(msnContact)
@@ -1166,7 +1171,7 @@ class NotificationClient(MSNEventBase):
         msnContact.status = params[0]
         msnContact.screenName = unquote(params[2])
         if len(params) > 3: msnContact.caps = int(params[3])
-        if len(params) > 4:
+        if len(params) > 4 and params[4] != "0":
             self.handleAvatarHelper(msnContact, params[4])
         else:
             self.handleAvatarGoneHelper(msnContact)