Mercurial > libervia-web
changeset 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 | 1d60fa4d25a4 |
children | e86490a7c76e |
files | src/browser/libervia_main.py src/browser/sat_browser/blog.py src/browser/sat_browser/game_radiocol.py src/browser/sat_browser/game_tarot.py src/browser/sat_browser/json.py src/browser/sat_browser/libervia_widget.py src/browser/sat_browser/plugin_sec_otr.py src/browser/sat_browser/xmlui.py src/server/blog.py src/server/server.py |
diffstat | 10 files changed, 50 insertions(+), 51 deletions(-) [+] |
line wrap: on
line diff
--- a/src/browser/libervia_main.py Thu Apr 16 13:29:26 2015 +0200 +++ b/src/browser/libervia_main.py Thu Apr 16 14:57:02 2015 +0200 @@ -258,14 +258,14 @@ return ret def registerWidget(self, wid): - log.debug("Registering %s" % wid.getDebugName()) + log.debug(u"Registering %s" % wid.getDebugName()) self.libervia_widgets.add(wid) def unregisterWidget(self, wid): try: self.libervia_widgets.remove(wid) except KeyError: - log.warning('trying to remove a non registered Widget: %s' % wid.getDebugName()) + log.warning(u'trying to remove a non registered Widget: %s' % wid.getDebugName()) def refresh(self): """Refresh the general display.""" @@ -369,7 +369,7 @@ def domain_cb(value): self._defaultDomain = value - log.info("new account domain: %s" % value) + log.info(u"new account domain: %s" % value) def domain_eb(value): self._defaultDomain = "libervia.org" @@ -418,7 +418,7 @@ return contact_list def newWidget(self, wid): - log.debug("newWidget: {}".format(wid)) + log.debug(u"newWidget: {}".format(wid)) self.addWidget(wid) def newMessageHandler(self, from_jid_s, msg, type_, to_jid_s, extra, profile=C.PROF_KEY_NONE): @@ -515,7 +515,7 @@ for publisher in mblogs: for mblog in mblogs[publisher][0]: if 'content' not in mblog: - log.warning("No content found in microblog [%s]" % mblog) + log.warning(u"No content found in microblog [%s]" % mblog) continue if 'groups' in mblog: _groups = set(mblog['groups'].split() if mblog['groups'] else []) @@ -626,7 +626,6 @@ elif event_type == 'MICROBLOG_DELETE': for wid in self.widgets.getWidgets(blog.MicroblogPanel): wid.removeEntry(data['type'], data['id']) - log.debug("%s %s %s" % (self.whoami.bare, sender, data['type'])) if sender == self.whoami.bare and data['type'] == 'main_item': for index in xrange(0, len(self.mblog_cache)): @@ -646,7 +645,7 @@ mblog_panel.addEntryIfAccepted(self.whoami.bare, *cache_entry) def getEntityMBlog(self, entity): - log.info("geting mblog for entity [%s]" % (entity,)) + log.info(u"geting mblog for entity [%s]" % (entity,)) for lib_wid in self.libervia_widgets: if isinstance(lib_wid, blog.MicroblogPanel): if lib_wid.isJidAccepted(entity):
--- a/src/browser/sat_browser/blog.py Thu Apr 16 13:29:26 2015 +0200 +++ b/src/browser/sat_browser/blog.py Thu Apr 16 14:57:02 2015 +0200 @@ -532,9 +532,9 @@ """ count_pub = len(mblogs) count_msg = sum([len(value) for value in mblogs.values()]) - log.debug("massive insertion of {count_msg} blogs for {count_pub} contacts".format(count_msg=count_msg, count_pub=count_pub)) + log.debug(u"massive insertion of {count_msg} blogs for {count_pub} contacts".format(count_msg=count_msg, count_pub=count_pub)) for publisher in mblogs: - log.debug("adding {count} blogs for [{publisher}]".format(count=len(mblogs[publisher]), publisher=publisher)) + log.debug(u"adding {count} blogs for [{publisher}]".format(count=len(mblogs[publisher]), publisher=publisher)) self.mblogsInsert(mblogs[publisher]) self.next_rsm_index += C.RSM_MAX_ITEMS self.footer.waiting = False @@ -551,7 +551,7 @@ for mblog in mblogs: if "content" not in mblog: - log.warning("No content found in microblog [%s]" % mblog) + log.warning(u"No content found in microblog [%s]" % mblog) continue self.addEntry(mblog, update_header=False)
--- a/src/browser/sat_browser/game_radiocol.py Thu Apr 16 13:29:26 2015 +0200 +++ b/src/browser/sat_browser/game_radiocol.py Thu Apr 16 14:57:02 2015 +0200 @@ -205,8 +205,8 @@ self.artist = artist self.album = album self.played = False - self.setSrc("radiocol/%s" % html_tools.html_sanitize(filename)) - log.debug("preloading %s in %s" % (title, self._id)) + self.setSrc(u"radiocol/%s" % html_tools.html_sanitize(filename)) + log.debug(u"preloading %s in %s" % (title, self._id)) def play(self, play=True): """Play or pause the song
--- a/src/browser/sat_browser/game_tarot.py Thu Apr 16 13:29:26 2015 +0200 +++ b/src/browser/sat_browser/game_tarot.py Thu Apr 16 14:57:02 2015 +0200 @@ -183,9 +183,9 @@ def _getTarotCardsPathsCb(paths): log.debug("_getTarotCardsPathsCb") for file_ in paths: - log.debug("path: %s" % file_) + log.debug(u"path: %s" % file_) card = CardWidget(self, file_) - log.debug("card: %s" % card) + log.debug(u"card: %s" % card) self.cards[(card.suit, card.value)] = card self.deck.append(card) self._parent.host.bridge.call('tarotGameReady', None, self.player_nick, self.referee)
--- a/src/browser/sat_browser/json.py Thu Apr 16 13:29:26 2015 +0200 +++ b/src/browser/sat_browser/json.py Thu Apr 16 14:57:02 2015 +0200 @@ -71,7 +71,7 @@ if kwargs: # kwargs should be empty here, we don't manage keyword arguments on bridge calls - log.error("kwargs is not empty after treatment on method call: kwargs={}".format(kwargs)) + log.error(u"kwargs is not empty after treatment on method call: kwargs={}".format(kwargs)) id_ = self._parent.callMethod(self._method, args) @@ -95,7 +95,7 @@ def _registerMethods(self, methods): if methods: for method in methods: - log.debug("Registering JSON method call [{}]".format(method)) + log.debug(u"Registering JSON method call [{}]".format(method)) setattr(self, method, getattr(LiberviaMethodProxy(self, method), 'call') @@ -108,7 +108,7 @@ def call(self, method, cb, *args): # FIXME: deprecated call method, must be removed once it's not used anymore id_ = self.callMethod(method, args) - log.debug("call: method={} [id={}], args={}".format(method, id_, args)) + log.debug(u"call: method={} [id={}], args={}".format(method, id_, args)) if cb: if isinstance(cb, tuple): if len(cb) != 2: @@ -155,9 +155,9 @@ dump(o)""" else: if isinstance(errobj['message'], dict): - log.error("Error %s: %s" % (errobj['message']['faultCode'], errobj['message']['faultString'])) + log.error(u"Error %s: %s" % (errobj['message']['faultCode'], errobj['message']['faultString'])) else: - log.error("%s" % errobj['message']) + log.error(u"%s" % errobj['message']) else: _eb((code, errobj)) del self.eb[request_info.id] @@ -237,7 +237,7 @@ log.info("Trying to reconnect to server...") self.getSignals(callback=self.signalHandler) # TODO: display a notification to user - log.warning("Lost connection, trying to reconnect in {} s".format(self.retry_delay/1000)) + log.warning(u"Lost connection, trying to reconnect in {} s".format(self.retry_delay / 1000)) Timer(notify=_timerCb).schedule(self.retry_delay) self.retry_delay *= 2 @@ -248,9 +248,9 @@ @param callback: method to call @param with_profile: True if the original bridge method need a profile """ - log.debug("Registering signal {}".format(name)) + log.debug(u"Registering signal {}".format(name)) if name in self._signals: - log.error("Trying to register and already registered signal ({})".format(name)) + log.error(u"Trying to register and already registered signal ({})".format(name)) else: self._signals[name] = (callback, with_profile) @@ -258,12 +258,12 @@ self.getSignals(callback=self.signalHandler) if len(signal_data) == 1: signal_data.append([]) - log.debug("Got signal ==> name: %s, params: %s" % (signal_data[0], signal_data[1])) + log.debug(u"Got signal ==> name: %s, params: %s" % (signal_data[0], signal_data[1])) name, args = signal_data try: callback, with_profile = self._signals[name] except KeyError: - log.warning("Ignoring {} signal: no handler registered !".format(name)) + log.warning(u"Ignoring {} signal: no handler registered !".format(name)) return if with_profile: args.append(C.PROF_KEY_NONE)
--- a/src/browser/sat_browser/libervia_widget.py Thu Apr 16 13:29:26 2015 +0200 +++ b/src/browser/sat_browser/libervia_widget.py Thu Apr 16 14:57:02 2015 +0200 @@ -165,8 +165,8 @@ if item_type and item_type[-1] == '\0': # Workaround for what looks like a pyjamas bug: the \0 should not be there, and item_type = item_type[:-1] # .strip('\0') and .replace('\0','') don't work. TODO: check this and fill a bug report # item_type = dt.getData("type") - log.debug("message: %s" % item) - log.debug("type: %s" % item_type) + log.debug(u"message: %s" % item) + log.debug(u"type: %s" % item_type) except: log.debug("no message found") item = ' ' @@ -290,8 +290,8 @@ if item_type and item_type[-1] == '\0': # Workaround for what looks like a pyjamas bug: the \0 should not be there, and item_type = item_type[:-1] # .strip('\0') and .replace('\0','') don't work. TODO: check this and fill a bug report # item_type = dt.getData("type") - log.debug("message: %s" % item) - log.debug("type: %s" % item_type) + log.debug(u"message: %s" % item) + log.debug(u"type: %s" % item_type) except: log.debug("no message found") item = ' ' @@ -618,7 +618,7 @@ def changeWidget(self, row, col, wid): """Change the widget in the given location, add row or columns when necessary""" - log.debug("changing widget: %s %s %s" % (wid.getDebugName(), row, col)) + log.debug(u"changing widget: %s %s %s" % (wid.getDebugName(), row, col)) last_row = max(0, self.flextable.getRowCount() - 1) # try: # FIXME: except without exception specified ! prev_wid = self.flextable.getWidget(row, col) @@ -681,7 +681,7 @@ def addWidget(self, wid): """Add a widget to a new cell on the next to last row""" last_row = max(0, self.flextable.getRowCount() - 1) - log.debug("putting widget %s at %d, %d" % (wid.getDebugName(), last_row, 0)) + log.debug(u"putting widget %s at %d, %d" % (wid.getDebugName(), last_row, 0)) self.changeWidget(last_row, 0, wid) def removeWidget(self, wid):
--- a/src/browser/sat_browser/plugin_sec_otr.py Thu Apr 16 13:29:26 2015 +0200 +++ b/src/browser/sat_browser/plugin_sec_otr.py Thu Apr 16 14:57:02 2015 +0200 @@ -160,8 +160,8 @@ def receiveMessageCb(self, msg, encrypted): assert isinstance(self.peer, jid.JID) if not encrypted: - log.warning("A plain-text message has been handled by otr.js") - log.debug("message received (was %s): %s" % ('encrypted' if encrypted else 'plain', msg)) + log.warning(u"A plain-text message has been handled by otr.js") + log.debug(u"message received (was %s): %s" % ('encrypted' if encrypted else 'plain', msg)) if not encrypted: if self.state == otr.context.STATE_ENCRYPTED: log.warning(u"Received unencrypted message in an encrypted context (from %(jid)s)" % {'jid': self.peer}) @@ -170,11 +170,11 @@ def sendMessageCb(self, msg, meta=None): assert isinstance(self.peer, jid.JID) - log.debug("message to send%s: %s" % ((' (attached meta data: %s)' % meta) if meta else '', msg)) + log.debug(u"message to send%s: %s" % ((' (attached meta data: %s)' % meta) if meta else '', msg)) self.host.bridge.call('sendMessage', (None, self.host.sendError), unicode(self.peer), msg, '', C.MESS_TYPE_CHAT, {'send_only': 'true'}) def messageErrorCb(self, error): - log.error('error occured: %s' % error) + log.error(u'error occured: %s' % error) def setStateCb(self, msg_state, status): if status == otr.context.STATUS_AKE_INIT: @@ -202,7 +202,7 @@ self.host.newMessageHandler(unicode(self.peer), feedback.format(jid=other_jid_s), C.MESS_TYPE_INFO, unicode(self.host.whoami), {'header_info': OTR.getInfoText(msg_state, trust)}) def setCurrentTrust(self, new_trust='', act='asked', type_='trust'): - log.debug("setCurrentTrust: trust={trust}, act={act}, type={type}".format(type=type_, trust=new_trust, act=act)) + log.debug(u"setCurrentTrust: trust={trust}, act={act}, type={type}".format(type=type_, trust=new_trust, act=act)) title = (AUTH_OTHER_TITLE if act == "asked" else AUTH_US_TITLE).format(jid=self.peer) old_trust = self.getCurrentTrust() if type_ == 'abort': @@ -255,7 +255,7 @@ - a boolean value telling if the authentication succeed when type_ is 'trust' @param act (unicode): a value in ('asked', 'answered') """ - log.debug("smpAuthCb: type={type}, data={data}, act={act}".format(type=type_, data=data, act=act)) + log.debug(u"smpAuthCb: type={type}, data={data}, act={act}".format(type=type_, data=data, act=act)) if act is None: if type_ == 'question': act = 'answered' # OTR._authenticate calls this method with act="asked"
--- a/src/browser/sat_browser/xmlui.py Thu Apr 16 13:29:26 2015 +0200 +++ b/src/browser/sat_browser/xmlui.py Thu Apr 16 14:57:02 2015 +0200 @@ -194,7 +194,7 @@ try: label = [label for label, _value in self._xmlui_attr_map.items() if _value == value][0] except IndexError: - log.warning("Can't find value [%s] to select" % value) + log.warning(u"Can't find value [%s] to select" % value) return self.selectItem(label)
--- a/src/server/blog.py Thu Apr 16 13:29:26 2015 +0200 +++ b/src/server/blog.py Thu Apr 16 14:57:02 2015 +0200 @@ -70,7 +70,7 @@ if key != 'avatar': return entity_jid_s = entity_jid_s.lower() - log.debug(_("Received a new avatar for entity %s") % entity_jid_s) + log.debug(_(u"Received a new avatar for entity %s") % entity_jid_s) avatar = C.AVATARS_DIR + value self.avatars_cache[entity_jid_s] = avatar try: @@ -95,7 +95,7 @@ entity_jid_s = [key for (key, value) in self.waiting_deferreds.items() if value[0] == action_id][0] except IndexError: # impossible to guess the entity return - log.debug(_("Using default avatar for entity %s") % entity_jid_s) + log.debug(_(u"Using default avatar for entity %s") % entity_jid_s) self.avatars_cache[entity_jid_s] = C.DEFAULT_AVATAR_URL self.waiting_deferreds[entity_jid_s][1].callback(C.DEFAULT_AVATAR_URL) del self.waiting_deferreds[entity_jid_s]
--- 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'):