summaryrefslogtreecommitdiff
path: root/sleekxmpp
diff options
context:
space:
mode:
authorNathan Fritz <nathan@andyet.net>2010-10-14 10:58:07 -0700
committerNathan Fritz <nathan@andyet.net>2010-10-14 10:58:07 -0700
commit0d0b963fe543169d069a2a69ae79735d404a2e33 (patch)
tree853d270219a799c884f26f3ed5806e407d5cac58 /sleekxmpp
parenta41a4369c6238f0d479d4190e79df6332c5b98fe (diff)
downloadslixmpp-0d0b963fe543169d069a2a69ae79735d404a2e33.tar.gz
slixmpp-0d0b963fe543169d069a2a69ae79735d404a2e33.tar.bz2
slixmpp-0d0b963fe543169d069a2a69ae79735d404a2e33.tar.xz
slixmpp-0d0b963fe543169d069a2a69ae79735d404a2e33.zip
fixed socket name collision in xmlstream.py and fixed python 3.x compatibility
Diffstat (limited to 'sleekxmpp')
-rw-r--r--sleekxmpp/clientxmpp.py3
-rw-r--r--sleekxmpp/plugins/stanza_pubsub.py2
-rw-r--r--sleekxmpp/test/sleektest.py2
-rw-r--r--sleekxmpp/thirdparty/statemachine.py8
-rw-r--r--sleekxmpp/xmlstream/xmlstream.py14
5 files changed, 14 insertions, 15 deletions
diff --git a/sleekxmpp/clientxmpp.py b/sleekxmpp/clientxmpp.py
index 1aab4a78..1816649a 100644
--- a/sleekxmpp/clientxmpp.py
+++ b/sleekxmpp/clientxmpp.py
@@ -162,7 +162,8 @@ class ClientXMPP(BaseXMPP):
intmax += answer.priority
addresses[intmax] = (answer.target.to_text()[:-1],
answer.port)
- priorities = addresses.keys()
+ #python3 returns a generator for dictionary keys
+ priorities = [x for x in addresses.keys()]
priorities.sort()
picked = random.randint(0, intmax)
diff --git a/sleekxmpp/plugins/stanza_pubsub.py b/sleekxmpp/plugins/stanza_pubsub.py
index 858e9281..2d809a35 100644
--- a/sleekxmpp/plugins/stanza_pubsub.py
+++ b/sleekxmpp/plugins/stanza_pubsub.py
@@ -290,7 +290,6 @@ class DefaultConfig(ElementBase):
def setConfig(self, value):
self['form'].setStanzaValues(value.getStanzaValues())
- print self['form']['title']
return self
registerStanzaPlugin(PubsubOwner, DefaultConfig)
@@ -370,7 +369,6 @@ class OwnerDefault(OwnerConfigure):
def setConfig(self, value):
self['form'].setStanzaValues(value.getStanzaValues())
- print self['from']['title']
return self
registerStanzaPlugin(PubsubOwner, OwnerDefault)
diff --git a/sleekxmpp/test/sleektest.py b/sleekxmpp/test/sleektest.py
index 5b2b91e8..9b822343 100644
--- a/sleekxmpp/test/sleektest.py
+++ b/sleekxmpp/test/sleektest.py
@@ -53,7 +53,7 @@ class SleekTest(unittest.TestCase):
try:
xml = ET.fromstring(xml_string)
return xml
- except SyntaxError, e:
+ except SyntaxError as e:
if 'unbound' in e.msg:
known_prefixes = {
'stream': 'http://etherx.jabber.org/streams'}
diff --git a/sleekxmpp/thirdparty/statemachine.py b/sleekxmpp/thirdparty/statemachine.py
index 140c0819..28a594b2 100644
--- a/sleekxmpp/thirdparty/statemachine.py
+++ b/sleekxmpp/thirdparty/statemachine.py
@@ -268,11 +268,11 @@ class _StateCtx:
if __name__ == '__main__':
def callback(s, s2):
- print 1, s.transition('on', 'off', wait=0.0, func=callback, args=[s,s2])
- print 2, s2.transition('off', 'on', func=callback, args=[s,s2])
+ print((1, s.transition('on', 'off', wait=0.0, func=callback, args=[s,s2])))
+ print((2, s2.transition('off', 'on', func=callback, args=[s,s2])))
return True
s = StateMachine(('off', 'on'))
s2 = StateMachine(('off', 'on'))
- print 3, s.transition('off', 'on', wait=0.0, func=callback, args=[s,s2]),
- print s.current_state(), s2.current_state()
+ print((3, s.transition('off', 'on', wait=0.0, func=callback, args=[s,s2]),))
+ print((s.current_state(), s2.current_state()))
diff --git a/sleekxmpp/xmlstream/xmlstream.py b/sleekxmpp/xmlstream/xmlstream.py
index 666ab0a2..97f71a22 100644
--- a/sleekxmpp/xmlstream/xmlstream.py
+++ b/sleekxmpp/xmlstream/xmlstream.py
@@ -10,7 +10,7 @@ from __future__ import with_statement, unicode_literals
import copy
import logging
-import socket
+import socket as Socket
import ssl
import sys
import threading
@@ -165,7 +165,7 @@ class XMLStream(object):
if sys.version_info < (3, 0):
self.socket_class = Socket26
else:
- self.socket_class = socket.socket
+ self.socket_class = Socket.socket
self.use_ssl = False
self.use_tls = False
@@ -247,7 +247,7 @@ class XMLStream(object):
def _connect(self):
self.stop.clear()
- self.socket = self.socket_class(socket.AF_INET, socket.SOCK_STREAM)
+ self.socket = self.socket_class(Socket.AF_INET, Socket.SOCK_STREAM)
self.socket.settimeout(None)
if self.use_ssl and self.ssl_support:
logging.debug("Socket Wrapped for SSL")
@@ -265,7 +265,7 @@ class XMLStream(object):
#this event is where you should set your application state
self.event("connected", direct=True)
return True
- except socket.error as serr:
+ except Socket.error as serr:
error_msg = "Could not connect. Socket Error #%s: %s"
logging.error(error_msg % (serr.errno, serr.strerror))
time.sleep(1)
@@ -297,8 +297,8 @@ class XMLStream(object):
try:
self.socket.close()
self.filesocket.close()
- self.socket.shutdown(socket.SHUT_RDWR)
- except socket.error as serr:
+ self.socket.shutdown(Socket.SHUT_RDWR)
+ except Socket.error as serr:
pass
finally:
#clear your application state
@@ -670,7 +670,7 @@ class XMLStream(object):
except SystemExit:
logging.debug("SystemExit in _process")
self.stop.set()
- except socket.error:
+ except Socket.error:
logging.exception('Socket Error')
except:
logging.exception('Connection error. Reconnecting.')