Mercurial > libervia-backend
diff src/plugins/plugin_exp_pipe.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_exp_pipe.py Fri Mar 28 18:06:51 2014 +0100 +++ b/src/plugins/plugin_exp_pipe.py Fri Mar 28 18:07:02 2014 +0100 @@ -23,9 +23,7 @@ from twisted.words.xish import domish from twisted.words.protocols.jabber import jid 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 @@ -82,8 +80,6 @@ info(_("EXP-PIPE file transfer requested")) debug(si_el.toXml()) client = self.host.getClient(profile) - if not client: - raise ProfileNotInCacheError pipe_elts = filter(lambda elt: elt.name == 'pipe', si_el.elements()) feature_elts = self.host.plugins["XEP-0020"].getFeatureElt(si_el) @@ -94,7 +90,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: @@ -122,8 +118,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, profile = client._pipe_waiting_for_approval[sid] if accepted: if timeout.active(): @@ -159,8 +153,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._pipe_waiting_for_approval[sid]) @@ -170,12 +162,10 @@ @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, profile = client._pipe_waiting_for_approval[sid] warning(_('Transfer %(id)s failed with stream method %(s_method)s') % {'id': sid, 's_method': stream_method}) - filepath = file_obj.name + # filepath = file_obj.name file_obj.close() #TODO: session remenber (within a time limit) when a stream method fail, and avoid that stream method with full jid for the rest of the session warning(_("All stream methods failed, can't transfer the file"))