core: use of the new core.log module:
/!\ this is a massive refactoring and was largely automated, it probably did bring some bugs /!\
This commit is contained in:
parent
dc5c042fe7
commit
501bc92528
1 changed files with 707 additions and 941 deletions
|
|
@ -19,7 +19,8 @@
|
|||
|
||||
from sat.core.i18n import _
|
||||
from sat.core.constants import Const as C
|
||||
from logging import debug, info, error
|
||||
from sat.core.log import getLogger
|
||||
log = getLogger(__name__)
|
||||
from twisted.words.xish import domish
|
||||
from twisted.words.protocols.jabber import client
|
||||
import uuid
|
||||
|
|
@ -52,7 +53,7 @@ PLUGIN_INFO = {
|
|||
class XEP_0095(object):
|
||||
|
||||
def __init__(self, host):
|
||||
info(_("Plugin XEP_0095 initialization"))
|
||||
log.info(_("Plugin XEP_0095 initialization"))
|
||||
self.host = host
|
||||
self.si_profiles = {} # key: SI profile, value: callback
|
||||
|
||||
|
|
@ -69,7 +70,7 @@ class XEP_0095(object):
|
|||
"""This method is called on stream initiation (XEP-0095 #3.2)
|
||||
@param iq_el: IQ element
|
||||
@param profile: %(doc_profile)s"""
|
||||
info(_("XEP-0095 Stream initiation"))
|
||||
log.info(_("XEP-0095 Stream initiation"))
|
||||
iq_el.handled = True
|
||||
si_el = iq_el.firstChildElement()
|
||||
si_id = si_el.getAttribute('id')
|
||||
|
|
@ -110,7 +111,7 @@ class XEP_0095(object):
|
|||
@param iq_id: IQ id
|
||||
@param to_jid: recipient
|
||||
@param profile: %(doc_profile)s"""
|
||||
self.sendError(iq_id, to_jid, 500, 'cancel', {'custom': 'failed'}, profile=profile) # as there is no error code for failed transfer, we use 500 (undefined-condition)
|
||||
self.sendError(iq_id, to_jid, 500, 'cancel', {'custom': 'failed'}, profile=profile) # as there is no lerror code for failed transfer, we use 500 (undefined-condition)
|
||||
|
||||
def sendError(self, iq_id, to_jid, err_code, err_type='cancel', data={}, profile=C.PROF_KEY_NONE):
|
||||
"""Send IQ error as a result
|
||||
|
|
@ -154,7 +155,7 @@ class XEP_0095(object):
|
|||
@param profile: %(doc_profile)s"""
|
||||
_client = self.host.getClient(profile)
|
||||
assert(_client)
|
||||
info(_("sending stream initiation accept answer"))
|
||||
log.info(_("sending stream initiation accept answer"))
|
||||
result = domish.Element((None, 'iq'))
|
||||
result['type'] = 'result'
|
||||
result['id'] = iq_id
|
||||
|
|
@ -176,12 +177,12 @@ class XEP_0095(object):
|
|||
@return: session id, offer"""
|
||||
current_jid, xmlstream = self.host.getJidNStream(profile_key)
|
||||
if not xmlstream:
|
||||
error(_('Asking for an non-existant or not connected profile'))
|
||||
log.error(_('Asking for an non-existant or not connected profile'))
|
||||
return ""
|
||||
|
||||
offer = client.IQ(xmlstream, 'set')
|
||||
sid = str(uuid.uuid4())
|
||||
debug(_("Stream Session ID: %s") % offer["id"])
|
||||
log.debug(_("Stream Session ID: %s") % offer["id"])
|
||||
|
||||
offer["from"] = current_jid.full()
|
||||
offer["to"] = to_jid.full()
|
||||
|
|
|
|||
Loading…
Reference in a new issue