diff src/memory/memory.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 b003dbd2b4e9
line wrap: on
line diff
--- a/src/memory/memory.py	Thu Apr 16 13:31:14 2015 +0200
+++ b/src/memory/memory.py	Thu Apr 16 14:57:57 2015 +0200
@@ -66,7 +66,7 @@
             session_id = str(uuid4())
         elif session_id in self._sessions:
             self._sessions[session_id][0].cancel()
-            log.warning("Session [{id}] is going to be re-initialised".format(id=session_id))
+            log.warning(u"Session [{id}] is going to be re-initialised".format(id=session_id))
         timer = reactor.callLater(self.timeout, self._purgeSession, session_id)
         if session_data is None:
             session_data = {}
@@ -75,7 +75,7 @@
 
     def _purgeSession(self, session_id):
         del self._sessions[session_id]
-        log.debug("Session [%s] purged" % session_id)
+        log.debug(u"Session [%s] purged" % session_id)
 
     def __len__(self):
         return len(self._sessions)
@@ -113,7 +113,7 @@
             timer.cancel()
             self._purgeSession(session_id)
         except KeyError:
-            log.debug("Session [%s] doesn't exists, timeout expired?" % session_id)
+            log.debug(u"Session [%s] doesn't exists, timeout expired?" % session_id)
 
     def keys(self):
         return self._sessions.keys()
@@ -204,7 +204,7 @@
     old_default = '~/.sat'
     if os.path.isfile(os.path.expanduser(old_default) + '/' + C.SAVEFILE_DATABASE):
         if not silent:
-            log.warning(_("A database has been found in the default local_dir for previous versions (< 0.5)"))
+            log.warning(_(u"A database has been found in the default local_dir for previous versions (< 0.5)"))
         tools_config.fixConfigOption('', 'local_dir', old_default, silent)
 
 
@@ -269,10 +269,10 @@
         if os.path.exists(filename):
             try:
                 self.params.load_xml(filename)
-                log.debug(_("Parameters loaded from file: %s") % filename)
+                log.debug(_(u"Parameters loaded from file: %s") % filename)
                 return True
             except Exception as e:
-                log.error(_("Can't load parameters from file: %s") % e)
+                log.error(_(u"Can't load parameters from file: %s") % e)
         return False
 
     def save_xml(self, filename):
@@ -287,10 +287,10 @@
         filename = os.path.expanduser(filename)
         try:
             self.params.save_xml(filename)
-            log.debug(_("Parameters saved to file: %s") % filename)
+            log.debug(_(u"Parameters saved to file: %s") % filename)
             return True
         except Exception as e:
-            log.error(_("Can't save parameters to file: %s") % e)
+            log.error(_(u"Can't save parameters to file: %s") % e)
         return False
 
     def load(self):
@@ -323,7 +323,7 @@
         def gotPersonalKey(personal_key):
             """Create the session for this profile and store the personal key"""
             self.auth_sessions.newSession({C.MEMORY_CRYPTO_KEY: personal_key}, profile=profile)
-            log.debug('auth session created for profile %s' % profile)
+            log.debug(u'auth session created for profile %s' % profile)
 
         d = PersistentDict(C.MEMORY_CRYPTO_NAMESPACE, profile).load()
         d.addCallback(lambda data: BlockCipher.decrypt(key, data[C.MEMORY_CRYPTO_KEY]))
@@ -337,7 +337,7 @@
         try:
             del self._entities_cache[profile]
         except KeyError:
-            log.error(_("Trying to purge roster status cache for a profile not in memory: [%s]") % profile)
+            log.error(_(u"Trying to purge roster status cache for a profile not in memory: [%s]") % profile)
 
     def getProfilesList(self):
         return self.storage.getProfilesList()
@@ -495,7 +495,7 @@
             try:
                 presence_data = self.getEntityDatum(full_jid, "presence", profile_key)
             except KeyError:
-                log.debug("Can't get presence data for {}".format(full_jid))
+                log.debug(u"Can't get presence data for {}".format(full_jid))
             else:
                 if presence_data.show != C.PRESENCE_UNAVAILABLE:
                     available.append(resource)
@@ -527,13 +527,13 @@
             try:
                 presence_data = self.getEntityDatum(full_jid, "presence", profile_key)
             except KeyError:
-                log.debug("No presence information for {}".format(full_jid))
+                log.debug(u"No presence information for {}".format(full_jid))
                 continue
             priority_resources.append((resource, presence_data.priority))
         try:
             return max(priority_resources, key=lambda res_tuple: res_tuple[1])[0]
         except ValueError:
-            log.warning("No resource found at all for {}".format(entity_jid))
+            log.warning(u"No resource found at all for {}".format(entity_jid))
             return None
 
     ## Entities data ##
@@ -801,7 +801,7 @@
             return d.addCallback(cb)
 
         def done(dummy):
-            log.debug(_('Personal data (%(ns)s, %(key)s) has been successfuly encrypted') %
+            log.debug(_(u'Personal data (%(ns)s, %(key)s) has been successfuly encrypted') %
                       {'ns': C.MEMORY_CRYPTO_NAMESPACE, 'key': data_key})
 
         d = PersistentDict(C.MEMORY_CRYPTO_NAMESPACE, profile).load()
@@ -887,6 +887,6 @@
         try:
             presence_data = self.getEntityDatum(entity_jid, "presence", profile_key)
         except KeyError:
-            log.debug("No presence information for {}".format(entity_jid))
+            log.debug(u"No presence information for {}".format(entity_jid))
             return False
         return presence_data.show != C.PRESENCE_UNAVAILABLE