Mercurial > libervia-backend
comparison src/plugins/plugin_xep_0100.py @ 1409:3265a2639182
massive (preventive) addition of 'u' (unicode) before the strings passed to logging functions
author | souliane <souliane@mailoo.org> |
---|---|
date | Thu, 16 Apr 2015 14:57:57 +0200 |
parents | 069ad98b360d |
children | 98f92a054539 |
comparison
equal
deleted
inserted
replaced
1408:8a7145138330 | 1409:3265a2639182 |
---|---|
123 @param identity: tuple as returned by Disco identities (category, type) | 123 @param identity: tuple as returned by Disco identities (category, type) |
124 | 124 |
125 """ | 125 """ |
126 category, type_ = identity | 126 category, type_ = identity |
127 if category != 'gateway': | 127 if category != 'gateway': |
128 log.error(_('INTERNAL ERROR: identity category should always be "gateway" in _getTypeString, got "%s"') % category) | 128 log.error(_(u'INTERNAL ERROR: identity category should always be "gateway" in _getTypeString, got "%s"') % category) |
129 try: | 129 try: |
130 return _(TYPE_DESCRIPTIONS[type_]) | 130 return _(TYPE_DESCRIPTIONS[type_]) |
131 except KeyError: | 131 except KeyError: |
132 return _("Unknown IM") | 132 return _("Unknown IM") |
133 | 133 |
165 ret.append((success, (msg, items[idx]))) | 165 ret.append((success, (msg, items[idx]))) |
166 else: | 166 else: |
167 entity = items[idx].entity | 167 entity = items[idx].entity |
168 gateways = [(identity, result.identities[identity]) for identity in result.identities if identity[0] == 'gateway'] | 168 gateways = [(identity, result.identities[identity]) for identity in result.identities if identity[0] == 'gateway'] |
169 if gateways: | 169 if gateways: |
170 log.info(_("Found gateway [%(jid)s]: %(identity_name)s") % {'jid': entity.full(), 'identity_name': ' - '.join([gateway[1] for gateway in gateways])}) | 170 log.info(_(u"Found gateway [%(jid)s]: %(identity_name)s") % {'jid': entity.full(), 'identity_name': ' - '.join([gateway[1] for gateway in gateways])}) |
171 ret.append((success, (entity, gateways))) | 171 ret.append((success, (entity, gateways))) |
172 else: | 172 else: |
173 log.info(_("Skipping [%(jid)s] which is not a gateway") % {'jid': entity.full()}) | 173 log.info(_(u"Skipping [%(jid)s] which is not a gateway") % {'jid': entity.full()}) |
174 return ret | 174 return ret |
175 | 175 |
176 def _itemsReceived(self, disco, target, client): | 176 def _itemsReceived(self, disco, target, client): |
177 """Look for items with disco protocol, and ask infos for each one""" | 177 """Look for items with disco protocol, and ask infos for each one""" |
178 | 178 |
180 log.debug(_("No gateway found")) | 180 log.debug(_("No gateway found")) |
181 return [] | 181 return [] |
182 | 182 |
183 _defers = [] | 183 _defers = [] |
184 for item in disco._items: | 184 for item in disco._items: |
185 log.debug(_("item found: %s") % item.entity) | 185 log.debug(_(u"item found: %s") % item.entity) |
186 _defers.append(client.disco.requestInfo(item.entity)) | 186 _defers.append(client.disco.requestInfo(item.entity)) |
187 dl = defer.DeferredList(_defers) | 187 dl = defer.DeferredList(_defers) |
188 dl.addCallback(self._infosReceived, items=disco._items, target=target, client=client) | 188 dl.addCallback(self._infosReceived, items=disco._items, target=target, client=client) |
189 reactor.callLater(GATEWAY_TIMEOUT, dl.cancel) | 189 reactor.callLater(GATEWAY_TIMEOUT, dl.cancel) |
190 return dl | 190 return dl |
201 | 201 |
202 def findGateways(self, target, profile): | 202 def findGateways(self, target, profile): |
203 """Find gateways in the target JID, using discovery protocol | 203 """Find gateways in the target JID, using discovery protocol |
204 """ | 204 """ |
205 client = self.host.getClient(profile) | 205 client = self.host.getClient(profile) |
206 log.debug(_("find gateways (target = %(target)s, profile = %(profile)s)") % {'target': target.full(), 'profile': profile}) | 206 log.debug(_(u"find gateways (target = %(target)s, profile = %(profile)s)") % {'target': target.full(), 'profile': profile}) |
207 d = client.disco.requestItems(target) | 207 d = client.disco.requestItems(target) |
208 d.addCallback(self._itemsReceived, target=target, client=client) | 208 d.addCallback(self._itemsReceived, target=target, client=client) |
209 return d | 209 return d |