Mercurial > libervia-backend
diff src/plugins/plugin_xep_0096.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_0096.py Fri Mar 28 18:06:51 2014 +0100 +++ b/src/plugins/plugin_xep_0096.py Fri Mar 28 18:07:02 2014 +0100 @@ -25,7 +25,6 @@ from twisted.words.protocols.jabber import error as jab_error import os from twisted.internet import reactor -from sat.core.exceptions import ProfileNotInCacheError from wokkel import data_form @@ -81,8 +80,6 @@ info(_("XEP-0096 file transfer requested")) debug(si_el.toXml()) client = self.host.getClient(profile) - if not client: - raise ProfileNotInCacheError filename = "" file_size = "" file_date = None @@ -111,7 +108,7 @@ if feature_elts: feature_el = feature_elts[0] - form = data_form.Form.fromElement(feature_el.firstChildElement()) + data_form.Form.fromElement(feature_el.firstChildElement()) try: stream_method = self.host.plugins["XEP-0020"].negociate(feature_el, 'stream-method', self.managed_stream_m) except KeyError: @@ -146,8 +143,6 @@ @param accepted: True if file transfer is accepted @param frontend_data: data sent by frontend""" client = self.host.getClient(profile) - if not client: - raise ProfileNotInCacheError data, timeout, stream_method, failed_methods = client._xep_0096_waiting_for_approval[sid] can_range = data['can_range'] == "True" range_offset = 0 @@ -192,8 +187,6 @@ """Called by the stream method when transfer successfuly finished @param id: stream id""" client = self.host.getClient(profile) - if not client: - raise ProfileNotInCacheError file_obj.close() info(_('Transfer %s successfuly finished') % sid) del(client._xep_0096_waiting_for_approval[sid]) @@ -203,8 +196,6 @@ @param id: stream id @param reason: can be TIMEOUT, IO_ERROR, PROTOCOL_ERROR""" client = self.host.getClient(profile) - if not client: - raise ProfileNotInCacheError data, timeout, stream_method, failed_methods = client._xep_0096_waiting_for_approval[sid] warning(_('Transfer %(id)s failed with stream method %(s_method)s: %(reason)s') % { 'id': sid,