summaryrefslogtreecommitdiff
path: root/sleekxmpp/plugins/xep_0045.py
diff options
context:
space:
mode:
authorLance Stout <lancestout@gmail.com>2011-08-17 21:30:47 -0700
committerLance Stout <lancestout@gmail.com>2011-08-17 21:30:47 -0700
commit004eabf80959ebcaeddf2e15065bd4f50ad10974 (patch)
treee62c243c6b1a539a0fa71030011eb88762068b6b /sleekxmpp/plugins/xep_0045.py
parent62230fc970f86b11bc74ee448e30cbe93f477e72 (diff)
downloadslixmpp-004eabf80959ebcaeddf2e15065bd4f50ad10974.tar.gz
slixmpp-004eabf80959ebcaeddf2e15065bd4f50ad10974.tar.bz2
slixmpp-004eabf80959ebcaeddf2e15065bd4f50ad10974.tar.xz
slixmpp-004eabf80959ebcaeddf2e15065bd4f50ad10974.zip
Update plugins that use Iq stanzas to work with new exceptions.
Diffstat (limited to 'sleekxmpp/plugins/xep_0045.py')
-rw-r--r--sleekxmpp/plugins/xep_0045.py42
1 files changed, 31 insertions, 11 deletions
diff --git a/sleekxmpp/plugins/xep_0045.py b/sleekxmpp/plugins/xep_0045.py
index 364fbbd9..338ed154 100644
--- a/sleekxmpp/plugins/xep_0045.py
+++ b/sleekxmpp/plugins/xep_0045.py
@@ -188,8 +188,12 @@ class xep_0045(base.base_plugin):
iq['from'] = ifrom
query = ET.Element('{http://jabber.org/protocol/muc#owner}query')
iq.append(query)
- result = iq.send()
- if result['type'] == 'error':
+ # For now, swallow errors to preserve existing API
+ try:
+ result = iq.send()
+ except IqError:
+ return False
+ except IqTimeout:
return False
xform = result.xml.find('{http://jabber.org/protocol/muc#owner}query/{jabber:x:data}x')
if xform is None: return False
@@ -209,8 +213,12 @@ class xep_0045(base.base_plugin):
form = form.getXML('submit')
query.append(form)
iq.append(query)
- result = iq.send()
- if result['type'] == 'error':
+ # For now, swallow errors to preserve existing API
+ try:
+ result = iq.send()
+ except IqError:
+ return False
+ except IqTimeout:
return False
return True
@@ -254,8 +262,12 @@ class xep_0045(base.base_plugin):
destroy.append(xreason)
query.append(destroy)
iq.append(query)
- r = iq.send()
- if r is False or r['type'] == 'error':
+ # For now, swallow errors to preserve existing API
+ try:
+ r = iq.send()
+ except IqError:
+ return False
+ except IqTimeout:
return False
return True
@@ -271,9 +283,13 @@ class xep_0045(base.base_plugin):
query.append(item)
iq = self.xmpp.makeIqSet(query)
iq['to'] = room
- result = iq.send()
- if result is False or result['type'] != 'result':
- raise ValueError
+ # For now, swallow errors to preserve existing API
+ try:
+ result = iq.send()
+ except IqError:
+ return False
+ except IqTimeout:
+ return False
return True
def invite(self, room, jid, reason='', mfrom=''):
@@ -303,8 +319,12 @@ class xep_0045(base.base_plugin):
iq = self.xmpp.makeIqGet('http://jabber.org/protocol/muc#owner')
iq['to'] = room
iq['from'] = ifrom
- result = iq.send()
- if result is None or result['type'] != 'result':
+ # For now, swallow errors to preserve existing API
+ try:
+ result = iq.send()
+ except IqError:
+ raise ValueError
+ except IqTimeout:
raise ValueError
form = result.xml.find('{http://jabber.org/protocol/muc#owner}query/{jabber:x:data}x')
if form is None: