diff src/plugins/plugin_xep_0095.py @ 941:c6d8fc63b1db

core, plugins: host.getClient now raise an exception instead of returning None when no profile is found, plugins have been adapted consequently and a bit cleaned
author Goffi <goffi@goffi.org>
date Fri, 28 Mar 2014 18:07:02 +0100
parents 1a759096ccbd
children 301b342c697a
line wrap: on
line diff
--- a/src/plugins/plugin_xep_0095.py	Fri Mar 28 18:06:51 2014 +0100
+++ b/src/plugins/plugin_xep_0095.py	Fri Mar 28 18:07:02 2014 +0100
@@ -21,11 +21,7 @@
 from sat.core.constants import Const as C
 from logging import debug, info, error
 from twisted.words.xish import domish
-from twisted.internet import protocol
-from twisted.words.protocols.jabber import client, jid
-from twisted.words.protocols.jabber import error as jab_error
-import os.path
-from twisted.internet import reactor
+from twisted.words.protocols.jabber import client
 import uuid
 
 from zope.interface import implements
@@ -125,8 +121,7 @@
         @param data: error specific data (dictionary)
         @param profile: %(doc_profile)s
         """
-        _client = self.host.getClient(profile)
-        assert(_client)
+        client_ = self.host.getClient(profile)
         result = domish.Element((None, 'iq'))
         result['type'] = 'result'
         result['id'] = iq_id
@@ -149,7 +144,7 @@
             if 'custom' in data and data['custom'] == 'failed':
                 condition_el.addContent('Stream failed')
 
-        _client.xmlstream.send(result)
+        client_.xmlstream.send(result)
 
     def acceptStream(self, iq_id, to_jid, feature_elt, misc_elts=[], profile=C.PROF_KEY_NONE):
         """Send the accept stream initiation answer