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
|
|
@ -20,7 +20,8 @@
|
|||
from sat.core.i18n import _
|
||||
from sat.core.constants import Const as C
|
||||
from sat.core import exceptions
|
||||
from logging import debug, info, warning, error
|
||||
from sat.core.log import getLogger
|
||||
log = getLogger(__name__)
|
||||
from twisted.words.protocols.jabber import jid
|
||||
from twisted.words.protocols.jabber.xmlstream import IQ
|
||||
from sat.tools import xml_tools
|
||||
|
|
@ -43,7 +44,7 @@ PLUGIN_INFO = {
|
|||
class XEP_0077(object):
|
||||
|
||||
def __init__(self, host):
|
||||
info(_("Plugin XEP_0077 initialization"))
|
||||
log.info(_("Plugin XEP_0077 initialization"))
|
||||
self.host = host
|
||||
self.triggers = {} # used by other protocol (e.g. XEP-0100) to finish registration. key = target_jid
|
||||
host.bridge.addMethod("inBandRegister", ".plugin", in_sign='ss', out_sign='s',
|
||||
|
|
@ -61,7 +62,7 @@ class XEP_0077(object):
|
|||
x_elem = query_elt.elements(data_form.NS_X_DATA, 'x').next()
|
||||
except StopIteration:
|
||||
# XXX: it seems we have an old service which doesn't manage data forms
|
||||
warning(_("Can't find data form"))
|
||||
log.warning(_("Can't find data form"))
|
||||
raise exceptions.DataError(_("This gateway can't be managed by SàT, sorry :("))
|
||||
|
||||
def submitForm(data, profile):
|
||||
|
|
@ -83,17 +84,17 @@ class XEP_0077(object):
|
|||
|
||||
def _regErr(self, failure, client):
|
||||
"""Called when something is wrong with registration"""
|
||||
info(_("Registration failure: %s") % str(failure.value))
|
||||
log.info(_("Registration failure: %s") % str(failure.value))
|
||||
raise failure
|
||||
|
||||
def _regSuccess(self, answer, client, post_treat_cb):
|
||||
debug(_("registration answer: %s") % answer.toXml())
|
||||
log.debug(_("registration answer: %s") % answer.toXml())
|
||||
if post_treat_cb is not None:
|
||||
post_treat_cb(jid.JID(answer['from']), client.profile)
|
||||
return {}
|
||||
|
||||
def _regFailure(self, failure, client):
|
||||
info(_("Registration failure: %s") % str(failure.value))
|
||||
log.info(_("Registration failure: %s") % str(failure.value))
|
||||
if failure.value.condition == 'conflict':
|
||||
raise exceptions.ConflictError( _("Username already exists, please choose an other one"))
|
||||
raise failure
|
||||
|
|
@ -104,7 +105,7 @@ class XEP_0077(object):
|
|||
def inBandRegister(self, to_jid, post_treat_cb=None, profile_key=C.PROF_KEY_NONE):
|
||||
"""register to a target JID"""
|
||||
client = self.host.getClient(profile_key)
|
||||
debug(_("Asking registration for [%s]") % to_jid.full())
|
||||
log.debug(_("Asking registration for [%s]") % to_jid.full())
|
||||
reg_request = IQ(client.xmlstream, 'get')
|
||||
reg_request["from"] = client.jid.full()
|
||||
reg_request["to"] = to_jid.full()
|
||||
|
|
|
|||
Loading…
Reference in a new issue