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
This commit is contained in:
parent
ed9df2984d
commit
a6897c76e0
1 changed files with 25 additions and 140 deletions
|
|
@ -25,7 +25,6 @@ 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
|
||||
|
||||
|
|
@ -81,8 +80,6 @@ class XEP_0096(object):
|
|||
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 @@ class XEP_0096(object):
|
|||
|
||||
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 @@ class XEP_0096(object):
|
|||
@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 @@ class XEP_0096(object):
|
|||
"""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 @@ class XEP_0096(object):
|
|||
@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,
|
||||
|
|
|
|||
Loading…
Reference in a new issue