]> code.delx.au - pymsnt/blobdiff - src/disco.py
Added auto-reconnect.
[pymsnt] / src / disco.py
index 3fb2fc90d4d4efe7a45933c0f3625e4fc5ff74d6..f9aac5b7e89208cf76f9d02d37a50b744fa37a13 100644 (file)
@@ -1,15 +1,17 @@
 # Copyright 2004-2005 James Bunton <james@delx.cjb.net>
 # Licensed for distribution under the GPL version 2, check COPYING for details
 
-import utils
-from tlib.xmlw import Element, jid
+from debug import LogEvent, INFO, WARN, ERROR
+
 from twisted.internet.defer import Deferred
 from twisted.internet import reactor
-from debug import LogEvent, INFO, WARN, ERROR
+from tlib.xmlw import Element, jid
+
 import sys
-import config
-import legacy
+
 import lang
+import utils
+import config
 
 XMPP_STANZAS  = "urn:ietf:params:xml:ns:xmpp-stanzas"
 DISCO         = "http://jabber.org/protocol/disco"
@@ -68,7 +70,7 @@ class ServerDiscovery:
                Returns a deferred which will fire with the matching IQ response as it's sole argument. """
                def checkDeferred():
                        if(not d.called):
-                               d.errback()
+                               d.errback("Timeout")
                                del self.deferredIqs[(jid, ID)]
 
                jid = el.getAttribute("to")
@@ -113,7 +115,7 @@ class ServerDiscovery:
                try: # Stringprep
                        froj = jid.intern(fro)
                        to = jid.intern(to).full()
-               except Exception, e:
+               except Exception:
                        LogEvent(WARN, "", "Dropping IQ because of stringprep error")
 
                # Check if it's a response to a send IQ
@@ -128,7 +130,7 @@ class ServerDiscovery:
                LogEvent(INFO, "", "Looking for handler")
 
                for query in el.elements():
-                       xmlns = query.defaultUri
+                       xmlns = query.uri
                        node = query.getAttribute("node")
                        
                        if xmlns.startswith(DISCO) and node:
@@ -230,6 +232,7 @@ class ServerDiscovery:
                error.attributes["type"] = etype
                error.attributes["code"] = str(utils.errorCodeMap[condition])
                cond = error.addElement(condition)
+               cond.attributes["xmlns"] = XMPP_STANZAS
                self.pytrans.send(el)