Mercurial > libervia-backend
diff src/plugins/plugin_xep_0100.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 | 9e24ca275ddd |
line wrap: on
line diff
--- a/src/plugins/plugin_xep_0100.py Sat Apr 19 16:48:26 2014 +0200 +++ b/src/plugins/plugin_xep_0100.py Sat Apr 19 19:19:19 2014 +0200 @@ -21,7 +21,8 @@ from sat.core.constants import Const as C from sat.core import exceptions from sat.tools import xml_tools -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.internet import reactor, defer @@ -55,7 +56,7 @@ class XEP_0100(object): def __init__(self, host): - info(_("Gateways plugin initialization")) + log.info(_("Gateways plugin initialization")) self.host = host self.__gateways = {} # dict used to construct the answer to findGateways. Key = target jid host.bridge.addMethod("findGateways", ".plugin", in_sign='ss', out_sign='s', method=self._findGateways) @@ -111,7 +112,7 @@ try: target_jid = jid.JID(data['index']) except (KeyError, RuntimeError): - warning(_("No gateway index selected")) + log.warning(_("No gateway index selected")) return {} d = self.gatewayRegister(target_jid, profile) @@ -125,7 +126,7 @@ """ category, type_ = identity if category != 'gateway': - error(_('INTERNAL ERROR: identity category should always be "gateway" in _getTypeString, got "%s"') % category) + log.error(_('INTERNAL ERROR: identity category should always be "gateway" in _getTypeString, got "%s"') % category) try: return _(TYPE_DESCRIPTIONS[type_]) except KeyError: @@ -133,7 +134,7 @@ def _registrationSuccessful(self, jid_, profile): """Called when in_band registration is ok, we must now follow the rest of procedure""" - debug(_("Registration successful, doing the rest")) + log.debug(_("Registration successful, doing the rest")) self.host.addContact(jid_, profile_key=profile) self.host.setPresence(jid_, profile_key=profile) @@ -167,22 +168,22 @@ entity = items[idx].entity gateways = [(identity, result.identities[identity]) for identity in result.identities if identity[0] == 'gateway'] if gateways: - info (_("Found gateway [%(jid)s]: %(identity_name)s") % {'jid': entity.full(), 'identity_name': ' - '.join([gateway[1] for gateway in gateways])}) + log.info (_("Found gateway [%(jid)s]: %(identity_name)s") % {'jid': entity.full(), 'identity_name': ' - '.join([gateway[1] for gateway in gateways])}) ret.append((success, (entity, gateways))) else: - info(_("Skipping [%(jid)s] which is not a gateway") % {'jid': entity.full()}) + log.info(_("Skipping [%(jid)s] which is not a gateway") % {'jid': entity.full()}) return ret def _itemsReceived(self, disco, target, client): """Look for items with disco protocol, and ask infos for each one""" if len(disco._items) == 0: - debug(_("No gateway found")) + log.debug(_("No gateway found")) return [] _defers = [] for item in disco._items: - debug(_("item found: %s"), item.entity) + log.debug(_("item found: %s"), item.entity) _defers.append(client.disco.requestInfo(item.entity)) dl = defer.DeferredList(_defers) dl.addCallback(self._infosReceived, items=disco._items, target=target, client=client) @@ -205,7 +206,7 @@ """Find gateways in the target JID, using discovery protocol """ client = self.host.getClient(profile) - debug(_("find gateways (target = %(target)s, profile = %(profile)s)") % {'target': target.full(), 'profile': profile}) + log.debug(_("find gateways (target = %(target)s, profile = %(profile)s)") % {'target': target.full(), 'profile': profile}) d = client.disco.requestItems(target) d.addCallback(self._itemsReceived , target=target, client=client) return d