diff src/server/server.py @ 694:82123705474b

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:02 +0200
parents 7a9c7b9f6a28
children c2f22ca12e23
line wrap: on
line diff
--- a/src/server/server.py	Thu Apr 16 13:29:26 2015 +0200
+++ b/src/server/server.py	Thu Apr 16 14:57:02 2015 +0200
@@ -131,7 +131,7 @@
     def purgeID(self, action_tuple):
         """Called when an action_id has not be handled in time"""
         if action_tuple in self.waiting_ids:
-            log.warning("action of action_id %s [%s] has not been managed, action_id is now ignored" % action_tuple)
+            log.warning(u"action of action_id %s [%s] has not been managed, action_id is now ignored" % action_tuple)
             del self.waiting_ids[action_tuple]
 
     def actionResultCb(self, answer_type, action_id, data, profile):
@@ -375,7 +375,7 @@
             # we keep a session cache for jid to avoir jid spoofing
             sat_jid = sat_session.jid = JID(self.sat_host.bridge.getParamA("JabberID", "Connection", profile_key=profile))
         if JID(from_jid).userhost() != sat_jid.userhost() and JID(to_jid).userhost() != sat_jid.userhost():
-            log.error("Trying to get history from a different jid (given (browser): {}, real (backend): {}), maybe a hack attempt ?".format(from_jid, sat_jid))
+            log.error(u"Trying to get history from a different jid (given (browser): {}, real (backend): {}), maybe a hack attempt ?".format(from_jid, sat_jid))
             return {}
         d = self.asyncBridgeCall("getHistory", from_jid, to_jid, size, between, search, profile)
 
@@ -545,7 +545,7 @@
         if category in self.authorized_params and name in self.authorized_params[category]:
             return self.sat_host.bridge.setParam(name, value, category, C.SECURITY_LIMIT, profile)
         else:
-            log.warning("Trying to set parameter '%s' in category '%s' without authorization!!!"
+            log.warning(u"Trying to set parameter '%s' in category '%s' without authorization!!!"
                     % (name, category))
 
     def jsonrpc_launchAction(self, callback_id, data):
@@ -711,16 +711,16 @@
             fault = failure.value.faultString
             self.waiting_profiles.purgeRequest(login_)
             if fault == 'PasswordError':
-                log.info("Profile %s doesn't exist or the submitted password is wrong" % login_)
+                log.info(u"Profile %s doesn't exist or the submitted password is wrong" % login_)
                 request.write(C.PROFILE_AUTH_ERROR)
             elif fault == 'SASLAuthError':
-                log.info("The XMPP password of profile %s is wrong" % login_)
+                log.info(u"The XMPP password of profile %s is wrong" % login_)
                 request.write(C.XMPP_AUTH_ERROR)
             elif fault == 'NoReply':
                 log.info(_("Did not receive a reply (the timeout expired or the connection is broken)"))
                 request.write(C.NO_REPLY)
             else:
-                log.error('Unmanaged fault string %s in errback for the connection of profile %s' % (fault, login_))
+                log.error(u'Unmanaged fault string %s in errback for the connection of profile %s' % (fault, login_))
                 request.write(C.UNKNOWN_ERROR % fault)
             request.finish()
 
@@ -765,7 +765,7 @@
             elif reason == "InternalError":
                 request.write(C.INTERNAL_ERROR)
             else:
-                log.error('Unknown registering error: %s' % (reason,))
+                log.error(u'Unknown registering error: %s' % (reason,))
                 request.write(C.UNKNOWN_ERROR % reason)
             request.finish()
 
@@ -796,7 +796,7 @@
         self.sat_host.prof_connected.add(profile)
 
         def onExpire():
-            log.info("Session expired (profile=%s)" % (profile,))
+            log.info(u"Session expired (profile=%s)" % (profile,))
             try:
                 #We purge the queue
                 del self.sat_host.signal_handler.queue[profile]
@@ -1132,7 +1132,7 @@
         self.bridge.getReady(lambda: self.initialised.callback(None),
                              lambda failure: self.initialised.errback(Exception(failure)))
         self.initialised.addCallback(backendReady)
-        self.initialised.addErrback(lambda failure: log.error("Init error: %s" % failure))
+        self.initialised.addErrback(lambda failure: log.error(u"Init error: %s" % failure))
 
     @property
     def version(self):
@@ -1164,7 +1164,7 @@
     def startService(self):
         """Connect the profile for Libervia and start the HTTP(S) server(s)"""
         def eb(e):
-            log.error(_("Connection failed: %s") % e)
+            log.error(_(u"Connection failed: %s") % e)
             self.stop()
 
         def initOk(dummy):
@@ -1189,10 +1189,10 @@
                     try:
                         cert = ssl.PrivateCertificate.loadPEM(keyAndCert.read())
                     except OpenSSL.crypto.Error as e:
-                        log.error(_("The file '%s' must contain both private and public parts of the certificate") % self.ssl_certificate)
+                        log.error(_(u"The file '%s' must contain both private and public parts of the certificate") % self.ssl_certificate)
                         raise e
             except IOError as e:
-                log.error(_("The file '%s' doesn't exist") % self.ssl_certificate)
+                log.error(_(u"The file '%s' doesn't exist") % self.ssl_certificate)
                 raise e
             reactor.listenSSL(self.port_https, self.site, cert.options())
         if self.connection_type in ('http', 'both'):