From 05c9ea5c1d953637343c9fad07267e7f89b20561 Mon Sep 17 00:00:00 2001 From: Nathan Fritz Date: Mon, 31 Aug 2009 22:46:31 +0000 Subject: * converted sleekxmpp to Python 3.x * sleekxmpp no longer spawns threads for callback handlers -- there are now two threads: one for handlers and one for reading. callback handlers can get results from the read queue directly with the "wait" handler which is used in .send() for the reply catching argument. --- sleekxmpp/plugins/xep_0009.py | 2 +- sleekxmpp/plugins/xep_0030.py | 10 +++------- sleekxmpp/plugins/xep_0045.py | 2 +- sleekxmpp/plugins/xep_0050.py | 3 +-- sleekxmpp/plugins/xep_0060.py | 1 - sleekxmpp/plugins/xep_0078.py | 6 +++--- sleekxmpp/plugins/xep_0086.py | 2 +- sleekxmpp/plugins/xep_0199.py | 4 ++-- 8 files changed, 12 insertions(+), 18 deletions(-) (limited to 'sleekxmpp/plugins') diff --git a/sleekxmpp/plugins/xep_0009.py b/sleekxmpp/plugins/xep_0009.py index c6b7b5df..e0da8296 100644 --- a/sleekxmpp/plugins/xep_0009.py +++ b/sleekxmpp/plugins/xep_0009.py @@ -2,7 +2,7 @@ XEP-0009 XMPP Remote Procedure Calls """ from __future__ import with_statement -import base +from . import base import logging from xml.etree import cElementTree as ET import copy diff --git a/sleekxmpp/plugins/xep_0030.py b/sleekxmpp/plugins/xep_0030.py index d3795308..fc921020 100644 --- a/sleekxmpp/plugins/xep_0030.py +++ b/sleekxmpp/plugins/xep_0030.py @@ -17,11 +17,9 @@ along with SleekXMPP; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA """ -from __future__ import absolute_import, with_statement from . import base import logging from xml.etree import cElementTree as ET -import thread class xep_0030(base.base_plugin): """ @@ -36,13 +34,11 @@ class xep_0030(base.base_plugin): self.items = {'main': []} self.xmpp.add_handler("" % self.xmpp.default_ns, self.info_handler) self.xmpp.add_handler("" % self.xmpp.default_ns, self.item_handler) - self.lock = thread.allocate_lock() def add_feature(self, feature, node='main'): - with self.lock: - if not self.features.has_key(node): - self.features[node] = [] - self.features[node].append(feature) + if not self.features.has_key(node): + self.features[node] = [] + self.features[node].append(feature) def add_identity(self, category=None, itype=None, name=None, node='main'): if not self.identities.has_key(node): diff --git a/sleekxmpp/plugins/xep_0045.py b/sleekxmpp/plugins/xep_0045.py index a85bfec8..b0523755 100644 --- a/sleekxmpp/plugins/xep_0045.py +++ b/sleekxmpp/plugins/xep_0045.py @@ -18,7 +18,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA """ from __future__ import with_statement -import base +from . import base import logging from xml.etree import cElementTree as ET diff --git a/sleekxmpp/plugins/xep_0050.py b/sleekxmpp/plugins/xep_0050.py index 80025c8b..20e10570 100644 --- a/sleekxmpp/plugins/xep_0050.py +++ b/sleekxmpp/plugins/xep_0050.py @@ -18,12 +18,11 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA """ from __future__ import with_statement -import base +from . import base import logging from xml.etree import cElementTree as ET import traceback import time -import thread class xep_0050(base.base_plugin): """ diff --git a/sleekxmpp/plugins/xep_0060.py b/sleekxmpp/plugins/xep_0060.py index b5e338ad..68c391f6 100644 --- a/sleekxmpp/plugins/xep_0060.py +++ b/sleekxmpp/plugins/xep_0060.py @@ -190,7 +190,6 @@ class xep_0060(base.base_plugin): id = iq.get('id') result = self.xmpp.send(iq, "" % id) if result is None or result.get('type') == 'error': - print "---------- returning false, apparently" return False return True diff --git a/sleekxmpp/plugins/xep_0078.py b/sleekxmpp/plugins/xep_0078.py index 28aaeb20..24afc875 100644 --- a/sleekxmpp/plugins/xep_0078.py +++ b/sleekxmpp/plugins/xep_0078.py @@ -20,8 +20,8 @@ from __future__ import with_statement from xml.etree import cElementTree as ET import logging -import sha -import base +import hashlib +from . import base class xep_0078(base.base_plugin): @@ -66,7 +66,7 @@ class xep_0078(base.base_plugin): else: logging.debug("Authenticating via jabber:iq:auth Digest") digest = ET.Element('digest') - digest.text = sha.sha("%s%s" % (self.streamid, self.xmpp.password)).hexdigest() + digest.text = hashlib.sha1(b"%s%s" % (self.streamid, self.xmpp.password)).hexdigest() query.append(digest) attempt.append(query) result = self.xmpp.send(attempt, self.xmpp.makeIq(self.xmpp.id)) diff --git a/sleekxmpp/plugins/xep_0086.py b/sleekxmpp/plugins/xep_0086.py index 6871ef3f..e6c18c77 100644 --- a/sleekxmpp/plugins/xep_0086.py +++ b/sleekxmpp/plugins/xep_0086.py @@ -1,6 +1,6 @@ from __future__ import with_statement -import base +from . import base import logging from xml.etree import cElementTree as ET import copy diff --git a/sleekxmpp/plugins/xep_0199.py b/sleekxmpp/plugins/xep_0199.py index cab84ac9..57d56c02 100644 --- a/sleekxmpp/plugins/xep_0199.py +++ b/sleekxmpp/plugins/xep_0199.py @@ -31,8 +31,8 @@ class xep_0199(base.base_plugin): self.xep = "0199" self.xmpp.add_handler("" % self.xmpp.default_ns, self.handler_ping) self.running = False - if self.config.get('keepalive', True): - self.xmpp.add_event_handler('session_start', self.handler_pingserver, threaded=True) + #if self.config.get('keepalive', True): + #self.xmpp.add_event_handler('session_start', self.handler_pingserver, threaded=True) def post_init(self): self.xmpp['xep_0030'].add_feature('http://www.xmpp.org/extensions/xep-0199.html#ns') -- cgit v1.2.3