summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xexamples/migrate_roster.py2
-rw-r--r--sleekxmpp/basexmpp.py4
-rw-r--r--sleekxmpp/clientxmpp.py7
-rw-r--r--sleekxmpp/jid.py5
-rw-r--r--sleekxmpp/plugins/xep_0096/file_transfer.py1
-rw-r--r--sleekxmpp/plugins/xep_0323/sensordata.py25
-rw-r--r--sleekxmpp/xmlstream/cert.py2
-rw-r--r--sleekxmpp/xmlstream/xmlstream.py9
8 files changed, 21 insertions, 34 deletions
diff --git a/examples/migrate_roster.py b/examples/migrate_roster.py
index 797e4f44..9f679523 100755
--- a/examples/migrate_roster.py
+++ b/examples/migrate_roster.py
@@ -113,7 +113,7 @@ def on_session2(event):
new_xmpp.update_roster(jid,
name = item['name'],
groups = item['groups'])
- new_xmpp.disconnect()
+ new_xmpp.disconnect()
new_xmpp.add_event_handler('session_start', on_session2)
if new_xmpp.connect():
diff --git a/sleekxmpp/basexmpp.py b/sleekxmpp/basexmpp.py
index 8cd61b63..cb72b9bd 100644
--- a/sleekxmpp/basexmpp.py
+++ b/sleekxmpp/basexmpp.py
@@ -55,8 +55,8 @@ class BaseXMPP(XMLStream):
is used during initialization.
"""
- def __init__(self, jid='', default_ns='jabber:client'):
- XMLStream.__init__(self)
+ def __init__(self, jid='', default_ns='jabber:client', **kwargs):
+ XMLStream.__init__(self, **kwargs)
self.default_ns = default_ns
self.stream_ns = 'http://etherx.jabber.org/streams'
diff --git a/sleekxmpp/clientxmpp.py b/sleekxmpp/clientxmpp.py
index 8db6ef17..31a5a70b 100644
--- a/sleekxmpp/clientxmpp.py
+++ b/sleekxmpp/clientxmpp.py
@@ -59,14 +59,15 @@ class ClientXMPP(BaseXMPP):
:param escape_quotes: **Deprecated.**
"""
- def __init__(self, jid, password, plugin_config=None, plugin_whitelist=None, escape_quotes=True, sasl_mech=None,
- lang='en'):
+ def __init__(self, jid, password, plugin_config=None,
+ plugin_whitelist=None, escape_quotes=True, sasl_mech=None,
+ lang='en', **kwargs):
if not plugin_whitelist:
plugin_whitelist = []
if not plugin_config:
plugin_config = {}
- BaseXMPP.__init__(self, jid, 'jabber:client')
+ BaseXMPP.__init__(self, jid, 'jabber:client', **kwargs)
self.escape_quotes = escape_quotes
self.plugin_config = plugin_config
diff --git a/sleekxmpp/jid.py b/sleekxmpp/jid.py
index ac5ba30d..613b272e 100644
--- a/sleekxmpp/jid.py
+++ b/sleekxmpp/jid.py
@@ -529,10 +529,6 @@ class JID(object):
return self._jid[0] or ''
@property
- def bare(self):
- return _format_jid(self._jid[0], self._jid[1])
-
- @property
def server(self):
return self._jid[1] or ''
@@ -556,7 +552,6 @@ class JID(object):
def bare(self):
return _format_jid(self._jid[0], self._jid[1])
-
@resource.setter
def resource(self, value):
self._jid = JID(self, resource=value)._jid
diff --git a/sleekxmpp/plugins/xep_0096/file_transfer.py b/sleekxmpp/plugins/xep_0096/file_transfer.py
index 6873c7f5..52ba2f27 100644
--- a/sleekxmpp/plugins/xep_0096/file_transfer.py
+++ b/sleekxmpp/plugins/xep_0096/file_transfer.py
@@ -47,6 +47,7 @@ class XEP_0096(BasePlugin):
data['size'] = size
data['date'] = date
data['desc'] = desc
+ data['hash'] = hash
if allow_ranged:
data.enable('range')
diff --git a/sleekxmpp/plugins/xep_0323/sensordata.py b/sleekxmpp/plugins/xep_0323/sensordata.py
index 30c28504..87a62980 100644
--- a/sleekxmpp/plugins/xep_0323/sensordata.py
+++ b/sleekxmpp/plugins/xep_0323/sensordata.py
@@ -15,7 +15,6 @@ from threading import Thread, Lock, Timer
from sleekxmpp.plugins.xep_0323.timerreset import TimerReset
-from sleekxmpp.xmlstream import JID
from sleekxmpp.xmlstream.handler import Callback
from sleekxmpp.xmlstream.matcher import StanzaPath
from sleekxmpp.plugins.base import BasePlugin
@@ -108,7 +107,6 @@ class XEP_0323(BasePlugin):
default_config = {
'threaded': True
-# 'session_db': None
}
def plugin_init(self):
@@ -161,11 +159,11 @@ class XEP_0323(BasePlugin):
self.last_seqnr = 0
self.seqnr_lock = Lock()
- ## For testning only
+ ## For testing only
self.test_authenticated_from = ""
def post_init(self):
- """ Init complete. Register our features in Serivce discovery. """
+ """ Init complete. Register our features in Service discovery. """
BasePlugin.post_init(self)
self.xmpp['xep_0030'].add_feature(Sensordata.namespace)
self.xmpp['xep_0030'].set_items(node=Sensordata.namespace, items=tuple())
@@ -301,8 +299,6 @@ class XEP_0323(BasePlugin):
self.sessions[session]["commTimers"] = {}
self.sessions[session]["nodeDone"] = {}
- #print("added session: " + str(self.sessions))
-
iq.reply()
iq['accepted']['seqnr'] = seqnr
if not request_delay_sec is None:
@@ -319,10 +315,8 @@ class XEP_0323(BasePlugin):
return
if self.threaded:
- #print("starting thread")
tr_req = Thread(target=self._threaded_node_request, args=(session, process_fields, req_flags))
tr_req.start()
- #print("started thread")
else:
self._threaded_node_request(session, process_fields, req_flags)
@@ -349,7 +343,6 @@ class XEP_0323(BasePlugin):
for node in self.sessions[session]["node_list"]:
timer = TimerReset(self.nodes[node]['commTimeout'], self._event_comm_timeout, args=(session, node))
self.sessions[session]["commTimers"][node] = timer
- #print("Starting timer " + str(timer) + ", timeout: " + str(self.nodes[node]['commTimeout']))
timer.start()
self.nodes[node]['device'].request_fields(process_fields, flags=flags, session=session, callback=self._device_field_request_callback)
@@ -377,7 +370,6 @@ class XEP_0323(BasePlugin):
msg['failure']['done'] = 'true'
msg.send()
# The session is complete, delete it
- #print("del session " + session + " due to timeout")
del self.sessions[session]
def _event_delayed_req(self, session, process_fields, req_flags):
@@ -404,7 +396,7 @@ class XEP_0323(BasePlugin):
def _all_nodes_done(self, session):
"""
- Checks wheter all devices are done replying to the readout.
+ Checks whether all devices are done replying to the readout.
Arguments:
session -- The request session id
@@ -448,7 +440,7 @@ class XEP_0323(BasePlugin):
Error details when a request failed.
"""
if not session in self.sessions:
- # This can happend if a session was deleted, like in a cancellation. Just drop the data.
+ # This can happen if a session was deleted, like in a cancellation. Just drop the data.
return
if result == "error":
@@ -467,7 +459,6 @@ class XEP_0323(BasePlugin):
if (self._all_nodes_done(session)):
msg['failure']['done'] = 'true'
# The session is complete, delete it
- # print("del session " + session + " due to error")
del self.sessions[session]
msg.send()
else:
@@ -494,7 +485,6 @@ class XEP_0323(BasePlugin):
msg['fields']['done'] = 'true'
if (self._all_nodes_done(session)):
# The session is complete, delete it
- # print("del session " + session + " due to complete")
del self.sessions[session]
else:
# Restart comm timer
@@ -536,14 +526,14 @@ class XEP_0323(BasePlugin):
def request_data(self, from_jid, to_jid, callback, nodeIds=None, fields=None, flags=None):
"""
- Called on the client side to initiade a data readout.
+ Called on the client side to initiate a data readout.
Composes a message with the request and sends it to the device(s).
Does not block, the callback will be called when data is available.
Arguments:
from_jid -- The jid of the requester
to_jid -- The jid of the device(s)
- callback -- The callback function to call when data is availble.
+ callback -- The callback function to call when data is available.
The callback function must support the following arguments:
@@ -664,7 +654,6 @@ class XEP_0323(BasePlugin):
Received Iq with cancelled - this is a cancel confirm.
Delete the session.
"""
- #print("Got cancelled")
seqnr = iq['cancelled']['seqnr']
callback = self.sessions[seqnr]["callback"]
callback(from_jid=iq['from'], result="cancelled")
@@ -673,7 +662,7 @@ class XEP_0323(BasePlugin):
def _handle_event_fields(self, msg):
"""
- Received Msg with fields - this is a data reponse to a request.
+ Received Msg with fields - this is a data response to a request.
If this is the last data block, issue a "done" callback.
"""
seqnr = msg['fields']['seqnr']
diff --git a/sleekxmpp/xmlstream/cert.py b/sleekxmpp/xmlstream/cert.py
index 71146f36..d357b326 100644
--- a/sleekxmpp/xmlstream/cert.py
+++ b/sleekxmpp/xmlstream/cert.py
@@ -181,4 +181,4 @@ def verify(expected, raw_cert):
return True
raise CertificateError(
- 'Could not match certficate against hostname: %s' % expected)
+ 'Could not match certificate against hostname: %s' % expected)
diff --git a/sleekxmpp/xmlstream/xmlstream.py b/sleekxmpp/xmlstream/xmlstream.py
index f9ec4947..62d46100 100644
--- a/sleekxmpp/xmlstream/xmlstream.py
+++ b/sleekxmpp/xmlstream/xmlstream.py
@@ -114,7 +114,8 @@ class XMLStream(object):
:param int port: The port to use for the connection. Defaults to 0.
"""
- def __init__(self, socket=None, host='', port=0):
+ def __init__(self, socket=None, host='', port=0, certfile=None,
+ keyfile=None, ca_certs=None, **kwargs):
#: Most XMPP servers support TLSv1, but OpenFire in particular
#: does not work well with it. For OpenFire, set
#: :attr:`ssl_version` to use ``SSLv23``::
@@ -136,16 +137,16 @@ class XMLStream(object):
#:
#: On Mac OS X, certificates in the system keyring will
#: be consulted, even if they are not in the provided file.
- self.ca_certs = None
+ self.ca_certs = ca_certs
#: Path to a file containing a client certificate to use for
#: authenticating via SASL EXTERNAL. If set, there must also
#: be a corresponding `:attr:keyfile` value.
- self.certfile = None
+ self.certfile = certfile
#: Path to a file containing the private key for the selected
#: client certificate to use for authenticating via SASL EXTERNAL.
- self.keyfile = None
+ self.keyfile = keyfile
self._der_cert = None