diff src/memory/params.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 c7fd121a6180
line wrap: on
line diff
--- a/src/memory/params.py	Thu Apr 16 13:31:14 2015 +0200
+++ b/src/memory/params.py	Thu Apr 16 14:57:57 2015 +0200
@@ -132,7 +132,7 @@
         try:
             del self.params[profile]
         except KeyError:
-            log.error(_("Trying to purge cache of a profile not in memory: [%s]") % profile)
+            log.error(_(u"Trying to purge cache of a profile not in memory: [%s]") % profile)
 
     def save_xml(self, filename):
         """Save parameters template to xml file"""
@@ -202,7 +202,7 @@
         elif return_profile_keys and profile_key in ["@ALL@"]:
             return profile_key # this value must be managed by the caller
         if not self.storage.hasProfile(profile_key):
-            log.error(_('Trying to access an unknown profile (%s)') % profile_key)
+            log.error(_(u'Trying to access an unknown profile (%s)') % profile_key)
             return "" # FIXME: raise exceptions.ProfileUnknownError here (must be well checked, this method is used in lot of places)
         return profile_key
 
@@ -283,23 +283,23 @@
         @param app: name of the frontend registering the parameters
         """
         if not app:
-            log.warning(_("Trying to register frontends parameters with no specified app: aborted"))
+            log.warning(_(u"Trying to register frontends parameters with no specified app: aborted"))
             return
         if not hasattr(self, "frontends_cache"):
             self.frontends_cache = []
         if app in self.frontends_cache:
-            log.debug(_("Trying to register twice frontends parameters for %(app)s: aborted" % {"app": app}))
+            log.debug(_(u"Trying to register twice frontends parameters for %(app)s: aborted" % {"app": app}))
             return
         self.frontends_cache.append(app)
         self.updateParams(xml, security_limit, app)
-        log.debug("Frontends parameters registered for %(app)s" % {'app': app})
+        log.debug(u"Frontends parameters registered for %(app)s" % {'app': app})
 
     def __default_ok(self, value, name, category):
         #FIXME: will not work with individual parameters
         self.setParam(name, value, category)
 
     def __default_ko(self, failure, name, category):
-        log.error(_("Can't determine default value for [%(category)s/%(name)s]: %(reason)s") % {'category': category, 'name': name, 'reason': str(failure.value)})
+        log.error(_(u"Can't determine default value for [%(category)s/%(name)s]: %(reason)s") % {'category': category, 'name': name, 'reason': str(failure.value)})
 
     def setDefault(self, name, category, callback, errback=None):
         """Set default value of parameter
@@ -314,7 +314,7 @@
         log.debug ("setDefault called for %(category)s/%(name)s" % {"category": category, "name": name})
         node = self._getParamNode(name, category, '@ALL@')
         if not node:
-            log.error(_("Requested param [%(name)s] in category [%(category)s] doesn't exist !") % {'name': name, 'category': category})
+            log.error(_(u"Requested param [%(name)s] in category [%(category)s] doesn't exist !") % {'name': name, 'category': category})
             return
         if node[1].getAttribute('default_cb') == 'yes':
             # del node[1].attributes['default_cb'] # default_cb is not used anymore as a flag to know if we have to set the default value,
@@ -354,9 +354,9 @@
                                  {'cat': cat, 'param': param, 'value': value_to_use})
                         return value_to_use
                     if len(selected) == 0:
-                        log.error(_('Parameter (%(cat)s, %(param)s) of type list has no default option!') % {'cat': cat, 'param': param})
+                        log.error(_(u'Parameter (%(cat)s, %(param)s) of type list has no default option!') % {'cat': cat, 'param': param})
                     else:
-                        log.error(_('Parameter (%(cat)s, %(param)s) of type list has more than one default option!') % {'cat': cat, 'param': param})
+                        log.error(_(u'Parameter (%(cat)s, %(param)s) of type list has more than one default option!') % {'cat': cat, 'param': param})
                     raise exceptions.DataError
             return value_to_use
         return node.getAttribute(attr)
@@ -432,7 +432,7 @@
         #FIXME: looks really dirty and buggy, need to be reviewed/refactored
         node = self._getParamNode(name, category)
         if not node:
-            log.error(_("Requested param [%(name)s] in category [%(category)s] doesn't exist !") % {'name': name, 'category': category})
+            log.error(_(u"Requested param [%(name)s] in category [%(category)s] doesn't exist !") % {'name': name, 'category': category})
             raise exceptions.NotFound
 
         if attr == 'value' and node[1].getAttribute('type') == 'password':
@@ -472,11 +472,11 @@
         """
         node = self._getParamNode(name, category)
         if not node:
-            log.error(_("Requested param [%(name)s] in category [%(category)s] doesn't exist !") % {'name': name, 'category': category})
+            log.error(_(u"Requested param [%(name)s] in category [%(category)s] doesn't exist !") % {'name': name, 'category': category})
             raise ValueError("Requested param doesn't exist")
 
         if not self.checkSecurityLimit(node[1], security_limit):
-            log.warning(_("Trying to get parameter '%(param)s' in category '%(cat)s' without authorization!!!"
+            log.warning(_(u"Trying to get parameter '%(param)s' in category '%(cat)s' without authorization!!!"
                       % {'param': name, 'cat': category}))
             raise exceptions.PermissionError
 
@@ -736,17 +736,17 @@
         if profile_key != C.PROF_KEY_NONE:
             profile = self.getProfileName(profile_key)
             if not profile:
-                log.error(_('Trying to set parameter for an unknown profile'))
+                log.error(_(u'Trying to set parameter for an unknown profile'))
                 raise exceptions.ProfileUnknownError
 
         node = self._getParamNode(name, category, '@ALL@')
         if not node:
-            log.error(_('Requesting an unknown parameter (%(category)s/%(name)s)')
+            log.error(_(u'Requesting an unknown parameter (%(category)s/%(name)s)')
                       % {'category': category, 'name': name})
             return defer.succeed(None)
 
         if not self.checkSecurityLimit(node[1], security_limit):
-            log.warning(_("Trying to set parameter '%(param)s' in category '%(cat)s' without authorization!!!"
+            log.warning(_(u"Trying to set parameter '%(param)s' in category '%(cat)s' without authorization!!!"
                           % {'param': name, 'cat': category}))
             return defer.succeed(None)
 
@@ -758,7 +758,7 @@
                 try:
                     int(value)
                 except ValueError:
-                    log.debug(_("Trying to set parameter '%(param)s' in category '%(cat)s' with an non-integer value"
+                    log.debug(_(u"Trying to set parameter '%(param)s' in category '%(cat)s' with an non-integer value"
                                 % {'param': name, 'cat': category}))
                     return defer.succeed(None)
                 if node[1].hasAttribute("constraint"):
@@ -786,7 +786,7 @@
 
         d_list = []
         if type_ == "button":
-            log.debug("Clicked param button %s" % node.toxml())
+            log.debug(u"Clicked param button %s" % node.toxml())
             return defer.succeed(None)
         d = defer.succeed(value)
         if type_ == "password":