Mercurial > libervia-backend
comparison src/core/xmpp.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 | f8ecce11a0bc |
children | 176de79c8c39 |
comparison
equal
deleted
inserted
replaced
1408:8a7145138330 | 1409:3265a2639182 |
---|---|
82 self.conn_deferred.callback(None) | 82 self.conn_deferred.callback(None) |
83 | 83 |
84 disco_d.addCallback(finish_connection) | 84 disco_d.addCallback(finish_connection) |
85 | 85 |
86 def initializationFailed(self, reason): | 86 def initializationFailed(self, reason): |
87 log.error(_("ERROR: XMPP connection failed for profile '%(profile)s': %(reason)s" % {'profile': self.profile, 'reason': reason})) | 87 log.error(_(u"ERROR: XMPP connection failed for profile '%(profile)s': %(reason)s" % {'profile': self.profile, 'reason': reason})) |
88 self.conn_deferred.errback(reason.value) | 88 self.conn_deferred.errback(reason.value) |
89 try: | 89 try: |
90 client.XMPPClient.initializationFailed(self, reason) | 90 client.XMPPClient.initializationFailed(self, reason) |
91 except: | 91 except: |
92 # we already chained an errback, no need to raise an exception | 92 # we already chained an errback, no need to raise an exception |
249 | 249 |
250 # we first remove item from local cache (self._groups and self._jids) | 250 # we first remove item from local cache (self._groups and self._jids) |
251 try: | 251 try: |
252 item = self._jids.pop(entity) | 252 item = self._jids.pop(entity) |
253 except KeyError: | 253 except KeyError: |
254 log.error("Received a roster remove event for an item not in cache ({})".format(entity)) | 254 log.error(u"Received a roster remove event for an item not in cache ({})".format(entity)) |
255 return | 255 return |
256 for group in item.groups: | 256 for group in item.groups: |
257 try: | 257 try: |
258 jids_set = self._groups[group] | 258 jids_set = self._groups[group] |
259 jids_set.remove(entity) | 259 jids_set.remove(entity) |
260 if not jids_set: | 260 if not jids_set: |
261 del self._groups[group] | 261 del self._groups[group] |
262 except KeyError: | 262 except KeyError: |
263 log.warning("there is no cache for the group [%(group)s] of the removed roster item [%(jid)s]" % | 263 log.warning(u"there is no cache for the group [%(group)s] of the removed roster item [%(jid)s]" % |
264 {"group": group, "jid": entity}) | 264 {"group": group, "jid": entity}) |
265 | 265 |
266 # then we send the bridge signal | 266 # then we send the bridge signal |
267 self.host.bridge.contactDeleted(entity.full(), self.parent.profile) | 267 self.host.bridge.contactDeleted(entity.full(), self.parent.profile) |
268 | 268 |
307 if not self.host.trigger.point("Presence send", self.parent, obj): | 307 if not self.host.trigger.point("Presence send", self.parent, obj): |
308 return | 308 return |
309 super(SatPresenceProtocol, self).send(obj) | 309 super(SatPresenceProtocol, self).send(obj) |
310 | 310 |
311 def availableReceived(self, entity, show=None, statuses=None, priority=0): | 311 def availableReceived(self, entity, show=None, statuses=None, priority=0): |
312 log.debug(_("presence update for [%(entity)s] (available, show=%(show)s statuses=%(statuses)s priority=%(priority)d)") % {'entity': entity, C.PRESENCE_SHOW: show, C.PRESENCE_STATUSES: statuses, C.PRESENCE_PRIORITY: priority}) | 312 log.debug(_(u"presence update for [%(entity)s] (available, show=%(show)s statuses=%(statuses)s priority=%(priority)d)") % {'entity': entity, C.PRESENCE_SHOW: show, C.PRESENCE_STATUSES: statuses, C.PRESENCE_PRIORITY: priority}) |
313 | 313 |
314 if not statuses: | 314 if not statuses: |
315 statuses = {} | 315 statuses = {} |
316 | 316 |
317 if None in statuses: # we only want string keys | 317 if None in statuses: # we only want string keys |
326 self.host.bridge.presenceUpdate(entity.full(), show or "", | 326 self.host.bridge.presenceUpdate(entity.full(), show or "", |
327 int(priority), statuses, | 327 int(priority), statuses, |
328 self.parent.profile) | 328 self.parent.profile) |
329 | 329 |
330 def unavailableReceived(self, entity, statuses=None): | 330 def unavailableReceived(self, entity, statuses=None): |
331 log.debug(_("presence update for [%(entity)s] (unavailable, statuses=%(statuses)s)") % {'entity': entity, C.PRESENCE_STATUSES: statuses}) | 331 log.debug(_(u"presence update for [%(entity)s] (unavailable, statuses=%(statuses)s)") % {'entity': entity, C.PRESENCE_STATUSES: statuses}) |
332 | 332 |
333 if not statuses: | 333 if not statuses: |
334 statuses = {} | 334 statuses = {} |
335 | 335 |
336 if None in statuses: # we only want string keys | 336 if None in statuses: # we only want string keys |
382 def unsubscribed(self, entity): | 382 def unsubscribed(self, entity): |
383 xmppim.PresenceClientProtocol.unsubscribed(self, entity) | 383 xmppim.PresenceClientProtocol.unsubscribed(self, entity) |
384 self.host.memory.delWaitingSub(entity.userhost(), self.parent.profile) | 384 self.host.memory.delWaitingSub(entity.userhost(), self.parent.profile) |
385 | 385 |
386 def subscribedReceived(self, entity): | 386 def subscribedReceived(self, entity): |
387 log.debug(_("subscription approved for [%s]") % entity.userhost()) | 387 log.debug(_(u"subscription approved for [%s]") % entity.userhost()) |
388 self.host.bridge.subscribe('subscribed', entity.userhost(), self.parent.profile) | 388 self.host.bridge.subscribe('subscribed', entity.userhost(), self.parent.profile) |
389 | 389 |
390 def unsubscribedReceived(self, entity): | 390 def unsubscribedReceived(self, entity): |
391 log.debug(_("unsubscription confirmed for [%s]") % entity.userhost()) | 391 log.debug(_(u"unsubscription confirmed for [%s]") % entity.userhost()) |
392 self.host.bridge.subscribe('unsubscribed', entity.userhost(), self.parent.profile) | 392 self.host.bridge.subscribe('unsubscribed', entity.userhost(), self.parent.profile) |
393 | 393 |
394 def subscribeReceived(self, entity): | 394 def subscribeReceived(self, entity): |
395 log.debug(_("subscription request from [%s]") % entity.userhost()) | 395 log.debug(_(u"subscription request from [%s]") % entity.userhost()) |
396 item = self.parent.roster.getItem(entity) | 396 item = self.parent.roster.getItem(entity) |
397 if item and item.subscriptionTo: | 397 if item and item.subscriptionTo: |
398 # We automatically accept subscription if we are already subscribed to contact presence | 398 # We automatically accept subscription if we are already subscribed to contact presence |
399 log.debug(_('sending automatic subscription acceptance')) | 399 log.debug(_('sending automatic subscription acceptance')) |
400 self.subscribed(entity) | 400 self.subscribed(entity) |
401 else: | 401 else: |
402 self.host.memory.addWaitingSub('subscribe', entity.userhost(), self.parent.profile) | 402 self.host.memory.addWaitingSub('subscribe', entity.userhost(), self.parent.profile) |
403 self.host.bridge.subscribe('subscribe', entity.userhost(), self.parent.profile) | 403 self.host.bridge.subscribe('subscribe', entity.userhost(), self.parent.profile) |
404 | 404 |
405 def unsubscribeReceived(self, entity): | 405 def unsubscribeReceived(self, entity): |
406 log.debug(_("unsubscription asked for [%s]") % entity.userhost()) | 406 log.debug(_(u"unsubscription asked for [%s]") % entity.userhost()) |
407 item = self.parent.roster.getItem(entity) | 407 item = self.parent.roster.getItem(entity) |
408 if item and item.subscriptionFrom: # we automatically remove contact | 408 if item and item.subscriptionFrom: # we automatically remove contact |
409 log.debug(_('automatic contact deletion')) | 409 log.debug(_('automatic contact deletion')) |
410 self.host.delContact(entity, self.parent.profile) | 410 self.host.delContact(entity, self.parent.profile) |
411 self.host.bridge.subscribe('unsubscribe', entity.userhost(), self.parent.profile) | 411 self.host.bridge.subscribe('unsubscribe', entity.userhost(), self.parent.profile) |
436 self.user_login = user_login | 436 self.user_login = user_login |
437 self.user_pass = user_pass | 437 self.user_pass = user_pass |
438 self.user_email = email | 438 self.user_email = email |
439 self.deferred = deferred | 439 self.deferred = deferred |
440 self.profile = profile | 440 self.profile = profile |
441 log.debug(_("Registration asked for %(user)s@%(host)s") % {'user': user_login, 'host': jabber_host}) | 441 log.debug(_(u"Registration asked for %(user)s@%(host)s") % {'user': user_login, 'host': jabber_host}) |
442 | 442 |
443 def connectionMade(self): | 443 def connectionMade(self): |
444 log.debug(_("Connection made with %s" % self.jabber_host)) | 444 log.debug(_(u"Connection made with %s" % self.jabber_host)) |
445 self.xmlstream.namespace = "jabber:client" | 445 self.xmlstream.namespace = "jabber:client" |
446 self.xmlstream.sendHeader() | 446 self.xmlstream.sendHeader() |
447 | 447 |
448 iq = compat.IQ(self.xmlstream, 'set') | 448 iq = compat.IQ(self.xmlstream, 'set') |
449 iq["to"] = self.jabber_host | 449 iq["to"] = self.jabber_host |
457 _email.addContent(self.user_email) | 457 _email.addContent(self.user_email) |
458 d = iq.send(self.jabber_host).addCallbacks(self.registrationAnswer, self.registrationFailure) | 458 d = iq.send(self.jabber_host).addCallbacks(self.registrationAnswer, self.registrationFailure) |
459 d.chainDeferred(self.deferred) | 459 d.chainDeferred(self.deferred) |
460 | 460 |
461 def registrationAnswer(self, answer): | 461 def registrationAnswer(self, answer): |
462 log.debug(_("Registration answer: %s") % answer.toXml()) | 462 log.debug(_(u"Registration answer: %s") % answer.toXml()) |
463 self.xmlstream.sendFooter() | 463 self.xmlstream.sendFooter() |
464 | 464 |
465 def registrationFailure(self, failure): | 465 def registrationFailure(self, failure): |
466 log.info(_("Registration failure: %s") % str(failure.value)) | 466 log.info(_("Registration failure: %s") % unicode(failure.value)) |
467 self.xmlstream.sendFooter() | 467 self.xmlstream.sendFooter() |
468 raise failure.value | 468 raise failure.value |
469 | 469 |
470 | 470 |
471 class SatVersionHandler(generic.VersionHandler): | 471 class SatVersionHandler(generic.VersionHandler): |