]> 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 98d2893ce3e512cdeb8fbcdb0e2ac1970c9220bd..835106cebd0caaa409c07e126c6fbcc5559ba581 100644 (file)
@@ -86,14 +86,7 @@ from __future__ import nested_scopes
 
 # Sibling imports
 from twisted.protocols.basic import LineReceiver
-try:
-    from twisted.web.http import HTTPClient
-except ImportError:
-    try:
-        from twisted.protocols.http import HTTPClient
-    except ImportError:
-        print "Couldn't find a HTTPClient. If you're using Twisted 2.0 make sure you've installed twisted.web"
-        raise
+from twisted.web.http import HTTPClient
 import msnp11chl
 
 # Twisted imports
@@ -527,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:
@@ -1137,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)
@@ -1173,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)