diff src/memory/sqlite.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 4fb3280c4568
line wrap: on
line diff
--- a/src/memory/sqlite.py	Thu Apr 16 13:31:14 2015 +0200
+++ b/src/memory/sqlite.py	Thu Apr 16 14:57:57 2015 +0200
@@ -114,7 +114,7 @@
 
             if statements is None:
                 return defer.succeed(None)
-            log.debug("===== COMMITING STATEMENTS =====\n%s\n============\n\n" % '\n'.join(statements))
+            log.debug(u"===== COMMITING STATEMENTS =====\n%s\n============\n\n" % '\n'.join(statements))
             d = self.dbpool.runInteraction(self._updateDb, tuple(statements))
             return d
 
@@ -170,7 +170,7 @@
         @param name: name of the profile
         @return: deferred triggered once profile is actually deleted"""
         def deletionError(failure):
-            log.error(_("Can't delete profile [%s]") % name)
+            log.error(_(u"Can't delete profile [%s]") % name)
             return failure
 
         def delete(txn):
@@ -194,7 +194,7 @@
             for param in result:
                 category, name, value = param
                 params_gen[(category, name)] = value
-        log.debug(_("loading general parameters from database"))
+        log.debug(_(u"loading general parameters from database"))
         return self.dbpool.runQuery("SELECT category,name,value FROM param_gen").addCallback(fillParams)
 
     def loadIndParams(self, params_ind, profile):
@@ -207,7 +207,7 @@
             for param in result:
                 category, name, value = param
                 params_ind[(category, name)] = value
-        log.debug(_("loading individual parameters from database"))
+        log.debug(_(u"loading individual parameters from database"))
         d = self.dbpool.runQuery("SELECT category,name,value FROM param_ind WHERE profile_id=?", (self.profiles[profile], ))
         d.addCallback(fillParams)
         return d
@@ -229,7 +229,7 @@
         @param value: value to set
         @return: deferred"""
         d = self.dbpool.runQuery("REPLACE INTO param_gen(category,name,value) VALUES (?,?,?)", (category, name, value))
-        d.addErrback(lambda ignore: log.error(_("Can't set general parameter (%(category)s/%(name)s) in database" % {"category": category, "name": name})))
+        d.addErrback(lambda ignore: log.error(_(u"Can't set general parameter (%(category)s/%(name)s) in database" % {"category": category, "name": name})))
         return d
 
     def setIndParam(self, category, name, value, profile):
@@ -240,7 +240,7 @@
         @param profile: a profile which *must* exist
         @return: deferred"""
         d = self.dbpool.runQuery("REPLACE INTO param_ind(category,name,profile_id,value) VALUES (?,?,?,?)", (category, name, self.profiles[profile], value))
-        d.addErrback(lambda ignore: log.error(_("Can't set individual parameter (%(category)s/%(name)s) for [%(profile)s] in database" % {"category": category, "name": name, "profile": profile})))
+        d.addErrback(lambda ignore: log.error(_(u"Can't set individual parameter (%(category)s/%(name)s) for [%(profile)s] in database" % {"category": category, "name": name, "profile": profile})))
         return d
 
     #History
@@ -260,7 +260,7 @@
         d = self.dbpool.runQuery("INSERT INTO history(source, source_res, dest, dest_res, timestamp, message, type, extra, profile_id) VALUES (?,?,?,?,?,?,?,?,?)",
                                  (from_jid.userhost(), from_jid.resource, to_jid.userhost(), to_jid.resource, timestamp or time(),
                                   message, _type, extra_, self.profiles[profile]))
-        d.addErrback(lambda ignore: log.error(_("Can't save following message in history: from [%(from_jid)s] to [%(to_jid)s] ==> [%(message)s]" %
+        d.addErrback(lambda ignore: log.error(_(u"Can't save following message in history: from [%(from_jid)s] to [%(to_jid)s] ==> [%(message)s]" %
                                           {"from_jid": from_jid.full(), "to_jid": to_jid.full(), "message": message})))
         return d
 
@@ -337,9 +337,9 @@
             for private in result:
                 key, value = private
                 private_gen[key] = value
-        log.debug(_("loading general private values [namespace: %s] from database") % (namespace, ))
+        log.debug(_(u"loading general private values [namespace: %s] from database") % (namespace,))
         d = self.dbpool.runQuery("SELECT key,value FROM private_gen WHERE namespace=?", (namespace, )).addCallback(fillPrivates)
-        return d.addErrback(lambda x: log.debug(_("No data present in database for namespace %s") % namespace))
+        return d.addErrback(lambda x: log.debug(_(u"No data present in database for namespace %s") % namespace))
 
     def loadIndPrivates(self, private_ind, namespace, profile):
         """Load individual private values
@@ -352,10 +352,10 @@
             for private in result:
                 key, value = private
                 private_ind[key] = value
-        log.debug(_("loading individual private values [namespace: %s] from database") % (namespace, ))
+        log.debug(_(u"loading individual private values [namespace: %s] from database") % (namespace,))
         d = self.dbpool.runQuery("SELECT key,value FROM private_ind WHERE namespace=? AND profile_id=?", (namespace, self.profiles[profile]))
         d.addCallback(fillPrivates)
-        return d.addErrback(lambda x: log.debug(_("No data present in database for namespace %s") % namespace))
+        return d.addErrback(lambda x: log.debug(_(u"No data present in database for namespace %s") % namespace))
 
     def setGenPrivate(self, namespace, key, value):
         """Save the general private value in database
@@ -364,7 +364,7 @@
         @param value: value to set
         @return: deferred"""
         d = self.dbpool.runQuery("REPLACE INTO private_gen(namespace,key,value) VALUES (?,?,?)", (namespace, key, value))
-        d.addErrback(lambda ignore: log.error(_("Can't set general private value (%(key)s) [namespace:%(namespace)s] in database" %
+        d.addErrback(lambda ignore: log.error(_(u"Can't set general private value (%(key)s) [namespace:%(namespace)s] in database" %
                      {"namespace": namespace, "key": key})))
         return d
 
@@ -376,7 +376,7 @@
         @param profile: a profile which *must* exist
         @return: deferred"""
         d = self.dbpool.runQuery("REPLACE INTO private_ind(namespace,key,profile_id,value) VALUES (?,?,?,?)", (namespace, key, self.profiles[profile], value))
-        d.addErrback(lambda ignore: log.error(_("Can't set individual private value (%(key)s) [namespace: %(namespace)s] for [%(profile)s] in database" %
+        d.addErrback(lambda ignore: log.error(_(u"Can't set individual private value (%(key)s) [namespace: %(namespace)s] for [%(profile)s] in database" %
                      {"namespace": namespace, "key": key, "profile": profile})))
         return d
 
@@ -386,7 +386,7 @@
         @param key: key of the private value
         @return: deferred"""
         d = self.dbpool.runQuery("DELETE FROM private_gen WHERE namespace=? AND key=?", (namespace, key))
-        d.addErrback(lambda ignore: log.error(_("Can't delete general private value (%(key)s) [namespace:%(namespace)s] in database" %
+        d.addErrback(lambda ignore: log.error(_(u"Can't delete general private value (%(key)s) [namespace:%(namespace)s] in database" %
                      {"namespace": namespace, "key": key})))
         return d
 
@@ -397,7 +397,7 @@
         @param profile: a profile which *must* exist
         @return: deferred"""
         d = self.dbpool.runQuery("DELETE FROM private_ind WHERE namespace=? AND key=? AND profile=?)", (namespace, key, self.profiles[profile]))
-        d.addErrback(lambda ignore: log.error(_("Can't delete individual private value (%(key)s) [namespace: %(namespace)s] for [%(profile)s] in database" %
+        d.addErrback(lambda ignore: log.error(_(u"Can't delete individual private value (%(key)s) [namespace: %(namespace)s] for [%(profile)s] in database" %
                      {"namespace": namespace, "key": key, "profile": profile})))
         return d
 
@@ -411,9 +411,9 @@
             for private in result:
                 key, value = private
                 private_gen[key] = pickle.loads(str(value))
-        log.debug(_("loading general private binary values [namespace: %s] from database") % (namespace, ))
+        log.debug(_(u"loading general private binary values [namespace: %s] from database") % (namespace,))
         d = self.dbpool.runQuery("SELECT key,value FROM private_gen_bin WHERE namespace=?", (namespace, )).addCallback(fillPrivates)
-        return d.addErrback(lambda x: log.debug(_("No binary data present in database for namespace %s") % namespace))
+        return d.addErrback(lambda x: log.debug(_(u"No binary data present in database for namespace %s") % namespace))
 
     def loadIndPrivatesBinary(self, private_ind, namespace, profile):
         """Load individual private binary values
@@ -426,10 +426,10 @@
             for private in result:
                 key, value = private
                 private_ind[key] = pickle.loads(str(value))
-        log.debug(_("loading individual private binary values [namespace: %s] from database") % (namespace, ))
+        log.debug(_(u"loading individual private binary values [namespace: %s] from database") % (namespace,))
         d = self.dbpool.runQuery("SELECT key,value FROM private_ind_bin WHERE namespace=? AND profile_id=?", (namespace, self.profiles[profile]))
         d.addCallback(fillPrivates)
-        return d.addErrback(lambda x: log.debug(_("No binary data present in database for namespace %s") % namespace))
+        return d.addErrback(lambda x: log.debug(_(u"No binary data present in database for namespace %s") % namespace))
 
     def setGenPrivateBinary(self, namespace, key, value):
         """Save the general private binary value in database
@@ -438,7 +438,7 @@
         @param value: value to set
         @return: deferred"""
         d = self.dbpool.runQuery("REPLACE INTO private_gen_bin(namespace,key,value) VALUES (?,?,?)", (namespace, key, pickle.dumps(value, 0)))
-        d.addErrback(lambda ignore: log.error(_("Can't set general private binary value (%(key)s) [namespace:%(namespace)s] in database" %
+        d.addErrback(lambda ignore: log.error(_(u"Can't set general private binary value (%(key)s) [namespace:%(namespace)s] in database" %
                      {"namespace": namespace, "key": key})))
         return d
 
@@ -450,7 +450,7 @@
         @param profile: a profile which *must* exist
         @return: deferred"""
         d = self.dbpool.runQuery("REPLACE INTO private_ind_bin(namespace,key,profile_id,value) VALUES (?,?,?,?)", (namespace, key, self.profiles[profile], pickle.dumps(value, 0)))
-        d.addErrback(lambda ignore: log.error(_("Can't set individual binary private value (%(key)s) [namespace: %(namespace)s] for [%(profile)s] in database" %
+        d.addErrback(lambda ignore: log.error(_(u"Can't set individual binary private value (%(key)s) [namespace: %(namespace)s] for [%(profile)s] in database" %
                      {"namespace": namespace, "key": key, "profile": profile})))
         return d
 
@@ -460,7 +460,7 @@
         @param key: key of the private value
         @return: deferred"""
         d = self.dbpool.runQuery("DELETE FROM private_gen_bin WHERE namespace=? AND key=?", (namespace, key))
-        d.addErrback(lambda ignore: log.error(_("Can't delete general private binary value (%(key)s) [namespace:%(namespace)s] in database" %
+        d.addErrback(lambda ignore: log.error(_(u"Can't delete general private binary value (%(key)s) [namespace:%(namespace)s] in database" %
                      {"namespace": namespace, "key": key})))
         return d
 
@@ -471,7 +471,7 @@
         @param profile: a profile which *must* exist
         @return: deferred"""
         d = self.dbpool.runQuery("DELETE FROM private_ind_bin WHERE namespace=? AND key=? AND profile=?)", (namespace, key, self.profiles[profile]))
-        d.addErrback(lambda ignore: log.error(_("Can't delete individual private binary value (%(key)s) [namespace: %(namespace)s] for [%(profile)s] in database" %
+        d.addErrback(lambda ignore: log.error(_(u"Can't delete individual private binary value (%(key)s) [namespace: %(namespace)s] for [%(profile)s] in database" %
                      {"namespace": namespace, "key": key, "profile": profile})))
         return d
     ##Helper methods##
@@ -781,7 +781,7 @@
                 try:
                     id_ = result[0][0]
                 except IndexError:
-                    log.error("Profile of id %d is referenced in 'param_ind' but it doesn't exist!" % profile_id)
+                    log.error(u"Profile of id %d is referenced in 'param_ind' but it doesn't exist!" % profile_id)
                     return defer.succeed(None)
 
                 sat_password = xmpp_password