Mercurial > libervia-backend
diff src/plugins/plugin_xep_0077.py @ 993:301b342c697a
core: use of the new core.log module:
/!\ this is a massive refactoring and was largely automated, it probably did bring some bugs /!\
author | Goffi <goffi@goffi.org> |
---|---|
date | Sat, 19 Apr 2014 19:19:19 +0200 |
parents | c6d8fc63b1db |
children | 069ad98b360d |
line wrap: on
line diff
--- a/src/plugins/plugin_xep_0077.py Sat Apr 19 16:48:26 2014 +0200 +++ b/src/plugins/plugin_xep_0077.py Sat Apr 19 19:19:19 2014 +0200 @@ -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 @@ 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 @@ 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 @@ 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 @@ 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()