diff 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
line wrap: on
line diff
--- a/src/core/xmpp.py	Thu Apr 16 13:31:14 2015 +0200
+++ b/src/core/xmpp.py	Thu Apr 16 14:57:57 2015 +0200
@@ -84,7 +84,7 @@
         disco_d.addCallback(finish_connection)
 
     def initializationFailed(self, reason):
-        log.error(_("ERROR: XMPP connection failed for profile '%(profile)s': %(reason)s" % {'profile': self.profile, 'reason': reason}))
+        log.error(_(u"ERROR: XMPP connection failed for profile '%(profile)s': %(reason)s" % {'profile': self.profile, 'reason': reason}))
         self.conn_deferred.errback(reason.value)
         try:
             client.XMPPClient.initializationFailed(self, reason)
@@ -251,7 +251,7 @@
         try:
             item = self._jids.pop(entity)
         except KeyError:
-            log.error("Received a roster remove event for an item not in cache ({})".format(entity))
+            log.error(u"Received a roster remove event for an item not in cache ({})".format(entity))
             return
         for group in item.groups:
             try:
@@ -260,7 +260,7 @@
                 if not jids_set:
                     del self._groups[group]
             except KeyError:
-                log.warning("there is no cache for the group [%(group)s] of the removed roster item [%(jid)s]" %
+                log.warning(u"there is no cache for the group [%(group)s] of the removed roster item [%(jid)s]" %
                             {"group": group, "jid": entity})
 
         # then we send the bridge signal
@@ -309,7 +309,7 @@
         super(SatPresenceProtocol, self).send(obj)
 
     def availableReceived(self, entity, show=None, statuses=None, priority=0):
-        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})
+        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})
 
         if not statuses:
             statuses = {}
@@ -328,7 +328,7 @@
                                         self.parent.profile)
 
     def unavailableReceived(self, entity, statuses=None):
-        log.debug(_("presence update for [%(entity)s] (unavailable, statuses=%(statuses)s)") % {'entity': entity, C.PRESENCE_STATUSES: statuses})
+        log.debug(_(u"presence update for [%(entity)s] (unavailable, statuses=%(statuses)s)") % {'entity': entity, C.PRESENCE_STATUSES: statuses})
 
         if not statuses:
             statuses = {}
@@ -384,15 +384,15 @@
         self.host.memory.delWaitingSub(entity.userhost(), self.parent.profile)
 
     def subscribedReceived(self, entity):
-        log.debug(_("subscription approved for [%s]") % entity.userhost())
+        log.debug(_(u"subscription approved for [%s]") % entity.userhost())
         self.host.bridge.subscribe('subscribed', entity.userhost(), self.parent.profile)
 
     def unsubscribedReceived(self, entity):
-        log.debug(_("unsubscription confirmed for [%s]") % entity.userhost())
+        log.debug(_(u"unsubscription confirmed for [%s]") % entity.userhost())
         self.host.bridge.subscribe('unsubscribed', entity.userhost(), self.parent.profile)
 
     def subscribeReceived(self, entity):
-        log.debug(_("subscription request from [%s]") % entity.userhost())
+        log.debug(_(u"subscription request from [%s]") % entity.userhost())
         item = self.parent.roster.getItem(entity)
         if item and item.subscriptionTo:
             # We automatically accept subscription if we are already subscribed to contact presence
@@ -403,7 +403,7 @@
             self.host.bridge.subscribe('subscribe', entity.userhost(), self.parent.profile)
 
     def unsubscribeReceived(self, entity):
-        log.debug(_("unsubscription asked for [%s]") % entity.userhost())
+        log.debug(_(u"unsubscription asked for [%s]") % entity.userhost())
         item = self.parent.roster.getItem(entity)
         if item and item.subscriptionFrom:  # we automatically remove contact
             log.debug(_('automatic contact deletion'))
@@ -438,10 +438,10 @@
         self.user_email = email
         self.deferred = deferred
         self.profile = profile
-        log.debug(_("Registration asked for %(user)s@%(host)s") % {'user': user_login, 'host': jabber_host})
+        log.debug(_(u"Registration asked for %(user)s@%(host)s") % {'user': user_login, 'host': jabber_host})
 
     def connectionMade(self):
-        log.debug(_("Connection made with %s" % self.jabber_host))
+        log.debug(_(u"Connection made with %s" % self.jabber_host))
         self.xmlstream.namespace = "jabber:client"
         self.xmlstream.sendHeader()
 
@@ -459,11 +459,11 @@
         d.chainDeferred(self.deferred)
 
     def registrationAnswer(self, answer):
-        log.debug(_("Registration answer: %s") % answer.toXml())
+        log.debug(_(u"Registration answer: %s") % answer.toXml())
         self.xmlstream.sendFooter()
 
     def registrationFailure(self, failure):
-        log.info(_("Registration failure: %s") % str(failure.value))
+        log.info(_("Registration failure: %s") % unicode(failure.value))
         self.xmlstream.sendFooter()
         raise failure.value