massive (preventive) addition of 'u' (unicode) before the strings passed to logging functions

This commit is contained in:
souliane 2015-04-16 14:57:57 +02:00
commit 67ff77e5de
32 changed files with 272 additions and 271 deletions

View file

@ -142,7 +142,7 @@ class CommandExport(object):
"""
profile = self.host.memory.getProfileName(profile_key)
if not profile:
log.warning("Unknown profile [%s]" % (profile,))
log.warning(u"Unknown profile [%s]" % (profile,))
return
for target in targets:

View file

@ -118,7 +118,7 @@ class Exp_Parrot(object):
_links = client.parrot_links = {}
_links[source_jid.userhostJID()] = dest_jid
log.info("Parrot mode: %s will be repeated to %s" % (source_jid.userhost(), unicode(dest_jid)))
log.info(u"Parrot mode: %s will be repeated to %s" % (source_jid.userhost(), unicode(dest_jid)))
def removeParrot(self, source_jid, profile):
"""Remove parrot link

View file

@ -68,7 +68,7 @@ class Exp_Pipe(object):
client = self.host.getClient(profile)
del client._pipe_waiting_for_approval[approval_id]
except KeyError:
log.warning(_("kill id called on a non existant approval id"))
log.warning(_(u"kill id called on a non existant approval id"))
def transferRequest(self, iq_id, from_jid, si_id, si_mime_type, si_el, profile):
"""Called when a pipe transfer is requested
@ -85,7 +85,7 @@ class Exp_Pipe(object):
feature_elts = self.host.plugins["XEP-0020"].getFeatureElt(si_el)
if not pipe_elts:
log.warning(_("No pipe element found"))
log.warning(_(u"No pipe element found"))
self.host.plugins["XEP-0095"].sendBadRequestError(iq_id, from_jid, profile)
return
@ -95,15 +95,15 @@ class Exp_Pipe(object):
try:
stream_method = self.host.plugins["XEP-0020"].negociate(feature_el, 'stream-method', self.managed_stream_m)
except KeyError:
log.warning(_("No stream method found"))
log.warning(_(u"No stream method found"))
self.host.plugins["XEP-0095"].sendBadRequestError(iq_id, from_jid, profile)
return
if not stream_method:
log.warning(_("Can't find a valid stream method"))
log.warning(_(u"Can't find a valid stream method"))
self.host.plugins["XEP-0095"].sendFailedError(iq_id, from_jid, profile)
return
else:
log.warning(_("No feature element found"))
log.warning(_(u"No feature element found"))
self.host.plugins["XEP-0095"].sendBadRequestError(iq_id, from_jid, profile)
return
@ -126,7 +126,7 @@ class Exp_Pipe(object):
try:
dest_path = frontend_data['dest_path']
except KeyError:
log.error(_('dest path not found in frontend_data'))
log.error(_(u'dest path not found in frontend_data'))
del(client._pipe_waiting_for_approval[sid])
return
if stream_method == self.host.plugins["XEP-0065"].NAMESPACE:
@ -136,7 +136,7 @@ class Exp_Pipe(object):
file_obj = open(dest_path, 'w+')
self.host.plugins["XEP-0047"].prepareToReceive(jid.JID(data['from']), sid, file_obj, None, self._transferSucceeded, self._transferFailed, profile)
else:
log.error(_("Unknown stream method, this should not happen at this stage, cancelling transfer"))
log.error(_(u"Unknown stream method, this should not happen at this stage, cancelling transfer"))
del(client._pipe_waiting_for_approval[sid])
return
@ -146,7 +146,7 @@ class Exp_Pipe(object):
misc_elts.append(domish.Element((PROFILE, "file")))
self.host.plugins["XEP-0095"].acceptStream(data["id"], data['from'], feature_elt, misc_elts, profile)
else:
log.debug(_("Transfer [%s] refused"), sid)
log.debug(_(u"Transfer [%s] refused"), sid)
self.host.plugins["XEP-0095"].sendRejectedError(data["id"], data['from'], profile=profile)
del(client._pipe_waiting_for_approval[sid])
@ -164,41 +164,41 @@ class Exp_Pipe(object):
@param reason: can be TIMEOUT, IO_ERROR, PROTOCOL_ERROR"""
client = self.host.getClient(profile)
data, timeout, stream_method, failed_methods, profile = client._pipe_waiting_for_approval[sid]
log.warning(_('Transfer %(id)s failed with stream method %(s_method)s') % {'id': sid,
log.warning(_(u'Transfer %(id)s failed with stream method %(s_method)s') % {'id': sid,
's_method': stream_method})
# filepath = file_obj.name
file_obj.close()
#TODO: session remenber (within a time limit) when a stream method fail, and avoid that stream method with full jid for the rest of the session
log.warning(_("All stream methods failed, can't transfer the file"))
log.warning(_(u"All stream methods failed, can't transfer the file"))
del(client._pipe_waiting_for_approval[sid])
def pipeCb(self, filepath, sid, profile, IQ):
if IQ['type'] == "error":
stanza_err = jabber.error.exceptionFromStanza(IQ)
if stanza_err.code == '403' and stanza_err.condition == 'forbidden':
log.debug(_("Pipe transfer refused by %s") % IQ['from'])
log.debug(_(u"Pipe transfer refused by %s") % IQ['from'])
self.host.bridge.newAlert(_("The contact %s refused your pipe stream") % IQ['from'], _("Pipe stream refused"), "INFO", profile)
else:
log.warning(_("Error during pipe stream transfer with %s") % IQ['from'])
log.warning(_(u"Error during pipe stream transfer with %s") % IQ['from'])
self.host.bridge.newAlert(_("Something went wrong during the pipe stream session intialisation with %s") % IQ['from'], _("Pipe stream error"), "ERROR", profile)
return
si_elt = IQ.firstChildElement()
if IQ['type'] != "result" or not si_elt or si_elt.name != "si":
log.error(_("Protocol error during file transfer"))
log.error(_(u"Protocol error during file transfer"))
return
feature_elts = self.host.plugins["XEP-0020"].getFeatureElt(si_elt)
if not feature_elts:
log.warning(_("No feature element"))
log.warning(_(u"No feature element"))
return
choosed_options = self.host.plugins["XEP-0020"].getChoosedOptions(feature_elts[0])
try:
stream_method = choosed_options["stream-method"]
except KeyError:
log.warning(_("No stream method choosed"))
log.warning(_(u"No stream method choosed"))
return
if stream_method == self.host.plugins["XEP-0065"].NAMESPACE:
@ -212,7 +212,7 @@ class Exp_Pipe(object):
file_obj = open(filepath, 'r') # XXX: we have to be sure that filepath is well opened, as reading can block it
self.host.plugins["XEP-0047"].startStream(file_obj, jid.JID(IQ['from']), sid, None, self.sendSuccessCb, self.sendFailureCb, None, profile)
else:
log.warning(_("Invalid stream method received"))
log.warning(_(u"Invalid stream method received"))
def pipeOut(self, to_jid, filepath, data={}, profile_key=C.PROF_KEY_NONE):
"""send a file using EXP-PIPE
@ -224,7 +224,7 @@ class Exp_Pipe(object):
"""
profile = self.host.memory.getProfileName(profile_key)
if not profile:
log.warning(_("Trying to send a file from an unknown profile"))
log.warning(_(u"Trying to send a file from an unknown profile"))
return ""
feature_elt = self.host.plugins["XEP-0020"].proposeFeatures({'stream-method': self.managed_stream_m})
@ -243,4 +243,4 @@ class Exp_Pipe(object):
def sendFailureCb(self, sid, file_obj, stream_method, reason, profile):
file_obj.close()
log.warning(_('Transfer %(id)s failed with stream method %(s_method)s %(profile)s') % {'id': sid, "s_method": stream_method, "profile": profile})
log.warning(_(u'Transfer %(id)s failed with stream method %(s_method)s %(profile)s') % {'id': sid, "s_method": stream_method, "profile": profile})

View file

@ -131,10 +131,10 @@ class MiscAccount(object):
if self._prosody_path is None:
paths = which(self.getConfig('prosodyctl'))
if not paths:
log.error(_("Can't find %s") % (self.getConfig('prosodyctl'), ))
log.error(_(u"Can't find %s") % (self.getConfig('prosodyctl'),))
else:
self._prosody_path = dirname(paths[0])
log.info(_('Prosody path found: %s') % (self._prosody_path, ))
log.info(_(u'Prosody path found: %s') % (self._prosody_path,))
self._sessions = Sessions()
@ -213,7 +213,7 @@ class MiscAccount(object):
def email_ko(ignore):
#TODO: return error code to user
log.error("Failed to send email to %s" % email)
log.error(u"Failed to send email to %s" % email)
body = (u"""Welcome to Libervia, a Salut à Toi project part

View file

@ -164,12 +164,12 @@ class GroupBlog(object):
# item_access_pubsubs = yield self.host.findFeaturesSet((NS_PUBSUB_ITEM_ACCESS, NS_PUBSUB_AUTO_CREATE, NS_PUBSUB_CREATOR_JID_CHECK), "pubsub", "service", profile_key=profile)
try:
client.item_access_pubsub = item_access_pubsubs.pop()
log.info(_("item-access powered pubsub service found: [%s]") % client.item_access_pubsub.full())
log.info(_(u"item-access powered pubsub service found: [%s]") % client.item_access_pubsub.full())
except KeyError:
client.item_access_pubsub = None
if not client.item_access_pubsub:
log.error(_("No item-access powered pubsub server found, can't use group blog"))
log.error(_(u"No item-access powered pubsub server found, can't use group blog"))
raise NoCompatiblePubSubServerFound
defer.returnValue((profile, client))
@ -187,7 +187,7 @@ class GroupBlog(object):
if (not (origin_host)
or len(event_host) < len(origin_host)
or event_host[-len(origin_host):] != origin_host):
log.warning("Host incoherence between %s and %s (hack attempt ?)" % (unicode(event.sender),
log.warning(u"Host incoherence between %s and %s (hack attempt ?)" % (unicode(event.sender),
unicode(publisher)))
return False
@ -398,10 +398,10 @@ class GroupBlog(object):
# remove the associated comments node
comments_service, comments_node = self.host.plugins["XEP-0277"].parseCommentUrl(comments)
d = self.host.plugins["XEP-0060"].deleteNode(comments_service, comments_node, profile_key=profile)
d.addErrback(lambda failure: log.error("Deletion of node %s failed: %s" % (comments_node, failure.getErrorMessage())))
d.addErrback(lambda failure: log.error(u"Deletion of node %s failed: %s" % (comments_node, failure.getErrorMessage())))
# remove the item itself
d = self.host.plugins["XEP-0060"].retractItems(service_jid, node, [item_id], profile_key=profile)
d.addErrback(lambda failure: log.error("Deletion of item %s from %s failed: %s" % (item_id, node, failure.getErrorMessage())))
d.addErrback(lambda failure: log.error(u"Deletion of item %s from %s failed: %s" % (item_id, node, failure.getErrorMessage())))
return d
def notify(d):
@ -450,7 +450,7 @@ class GroupBlog(object):
self.__fillCommentsElement(mblog_data, entry_id, node, service_jid)
entry_d = self.host.plugins["XEP-0277"].data2entry(mblog_data, profile)
entry_d.addCallback(lambda mblog_item: self.host.plugins["XEP-0060"].publish(service_jid, node, items=[mblog_item], profile_key=profile))
entry_d.addErrback(lambda failure: log.error("Modification of %s failed: %s" % (pub_data, failure.getErrorMessage())))
entry_d.addErrback(lambda failure: log.error(u"Modification of %s failed: %s" % (pub_data, failure.getErrorMessage())))
return entry_d
return self._initialise(profile_key).addCallback(initialised)
@ -494,14 +494,14 @@ class GroupBlog(object):
try:
gbdata['service'] = client.item_access_pubsub.full()
except AttributeError:
log.warning(_("Pubsub service is unknown for blog entry %s") % gbdata['id'])
log.warning(_(u"Pubsub service is unknown for blog entry %s") % gbdata['id'])
# every comments node must be subscribed, except if we are the publisher (we are already subscribed in this case)
if "comments_node" in gbdata and pub_jid.userhostJID() != client.jid.userhostJID():
try:
service = jid.JID(gbdata["comments_service"])
node = gbdata["comments_node"]
except KeyError:
log.error(_("Missing key for blog comment %s") % gbdata['id'])
log.error(_(u"Missing key for blog comment %s") % gbdata['id'])
defer.returnValue(gbdata)
# TODO: see if it is really needed to check for not subscribing twice to the node
# It previously worked without this check, but the pubsub service logs were polluted
@ -766,14 +766,14 @@ class GroupBlog(object):
d_list = []
for node in [node for node in nodes if node.endswith(main_node)]:
d = self.host.plugins["XEP-0060"].deleteNode(service, node, profile_key=profile)
d.addErrback(lambda failure: log.error(_("Deletion of node %(node)s failed: %(message)s") %
d.addErrback(lambda failure: log.error(_(u"Deletion of node %(node)s failed: %(message)s") %
{'node': node, 'message': failure.getErrorMessage()}))
d_list.append(d)
return defer.DeferredList(d_list)
d = self.host.plugins["XEP-0060"].listNodes(service, profile=profile)
d.addCallback(cb)
d.addCallback(lambda dummy: log.info(_("All microblog's main items from %s have been deleted!") % jid_.userhost()))
d.addCallback(lambda dummy: log.info(_(u"All microblog's main items from %s have been deleted!") % jid_.userhost()))
return d
return self._initialise(profile_key).addCallback(initialised)
@ -797,7 +797,7 @@ class GroupBlog(object):
main_node = self.getNodeName(jid_)
d = self.host.plugins["XEP-0060"].getItems(service, main_node, profile_key=profile)
d.addCallback(lambda res: getComments(res[0], client))
d.addErrback(lambda failure, main_node: log.error(_("Retrieval of items for node %(node)s failed: %(message)s") %
d.addErrback(lambda failure, main_node: log.error(_(u"Retrieval of items for node %(node)s failed: %(message)s") %
{'node': main_node, 'message': failure.getErrorMessage()}), main_node)
blogs.append(d)
@ -820,7 +820,7 @@ class GroupBlog(object):
service, node = self.host.plugins['XEP-0277'].parseCommentUrl(href)
d = self.host.plugins["XEP-0060"].getItems(service, node, profile_key=profile_key)
d.addCallback(lambda items: (service, node, items[0]))
d.addErrback(lambda failure, node: log.error(_("Retrieval of comments for node %(node)s failed: %(message)s") %
d.addErrback(lambda failure, node: log.error(_(u"Retrieval of comments for node %(node)s failed: %(message)s") %
{'node': node, 'message': failure.getErrorMessage()}), node)
comments.append(d)
dlist = defer.DeferredList(comments)
@ -852,9 +852,9 @@ class GroupBlog(object):
deletions = []
if item_ids: # remove the comments of the user on the given post
d = self.host.plugins['XEP-0060'].retractItems(service, node_id, item_ids, profile_key=profile_key)
d.addCallback(lambda dummy, node_id: log.debug(_('Comments of user %(user)s in node %(node)s have been retracted') %
d.addCallback(lambda dummy, node_id: log.debug(_(u'Comments of user %(user)s in node %(node)s have been retracted') %
{'user': user_jid_s, 'node': node_id}), node_id)
d.addErrback(lambda failure, node_id: log.error(_("Retraction of comments from %(user)s in node %(node)s failed: %(message)s") %
d.addErrback(lambda failure, node_id: log.error(_(u"Retraction of comments from %(user)s in node %(node)s failed: %(message)s") %
{'user': user_jid_s, 'node': node_id, 'message': failure.getErrorMessage()}), node_id)
deletions.append(d)
return defer.DeferredList(deletions)

View file

@ -108,7 +108,7 @@ class Message(object):
should be omitted from the return value, rather than included.
@return: A mapping of header field names to header field values
"""
log.debug('getHeaders %s - %s' % (negate, names))
log.debug(u'getHeaders %s - %s' % (negate, names))
final_dict = {}
to_check = [name.lower() for name in names]
for header in self.message.keys():
@ -151,7 +151,7 @@ class SatMailbox(object):
def __init__(self, host, name, profile):
self.host = host
self.listeners = set()
log.debug('Mailbox init (%s)' % name)
log.debug(u'Mailbox init (%s)' % name)
if name != "INBOX":
raise imap4.MailboxException("Only INBOX is managed for the moment")
self.mailbox = self.host.plugins["Maildir"].accessMessageBox(name, self.newMessage, profile)
@ -180,7 +180,7 @@ class SatMailbox(object):
@param message: The message sequence number
@return: The UID of the message.
"""
log.debug('getUID (%i)' % message)
log.debug(u'getUID (%i)' % message)
#return self.mailbox.getUid(message-1) #XXX: it seems that this method get uid and not message sequence number
return message
@ -236,7 +236,7 @@ class SatMailbox(object):
@param listener: An object to add to the set of those which will
be notified when the contents of this mailbox change.
"""
log.debug('addListener %s' % listener)
log.debug(u'addListener %s' % listener)
self.listeners.add(listener)
def removeListener(self, listener):
@ -281,7 +281,7 @@ class SatMailbox(object):
about
@param uid: If true, the IDs specified in the query are UIDs;
"""
log.debug('fetch (%s, %s)' % (messages, uid))
log.debug(u'fetch (%s, %s)' % (messages, uid))
if uid:
messages.last = self.mailbox.getMaxUid()
messages.getnext = self.mailbox.getNextExistingUid
@ -436,7 +436,7 @@ class ImapServerFactory(protocol.ServerFactory):
log.debug(_("IMAP server connection started"))
def clientConnectionLost(self, connector, reason):
log.debug(_("IMAP server connection lost (reason: %s)"), reason)
log.debug(_(u"IMAP server connection lost (reason: %s)"), reason)
def buildProtocol(self, addr):
log.debug("Building protocol")

View file

@ -128,7 +128,7 @@ class MaildirBox(object):
@param mailboxUser: MailboxUser instance"""
if boxname not in self.__mailboxes:
err_msg = _("Trying to remove an mailboxUser not referenced")
log.error(_("INTERNAL ERROR: ") + err_msg)
log.error(_(u"INTERNAL ERROR: ") + err_msg)
raise MaildirError(err_msg)
assert self.__mailboxes[profile][boxname] == mailboxUser
del self.__mailboxes[profile][boxname]
@ -147,7 +147,7 @@ class MaildirBox(object):
return self.data[profile][boxname] # the boxname MUST exist in the data
except KeyError:
err_msg = _("Boxname doesn't exist in internal data")
log.error(_("INTERNAL ERROR: ") + err_msg)
log.error(_(u"INTERNAL ERROR: ") + err_msg)
raise MaildirError(err_msg)
def getUid(self, boxname, message_id, profile):
@ -285,22 +285,22 @@ class MaildirBox(object):
@param boxname: name of the box which was observed
@param signal: which signal was observed by the caller"""
if (profile, boxname) not in self.__observed:
err_msg = _("Trying to remove an observer for an inexistant mailbox")
log.error(_("INTERNAL ERROR: ") + err_msg)
err_msg = _(u"Trying to remove an observer for an inexistant mailbox")
log.error(_(u"INTERNAL ERROR: ") + err_msg)
raise MaildirError(err_msg)
if signal not in self.__observed[(profile, boxname)]:
err_msg = _("Trying to remove an inexistant observer, no observer for this signal")
log.error(_("INTERNAL ERROR: ") + err_msg)
err_msg = _(u"Trying to remove an inexistant observer, no observer for this signal")
log.error(_(u"INTERNAL ERROR: ") + err_msg)
raise MaildirError(err_msg)
if not callback in self.__observed[(profile, boxname)][signal]:
err_msg = _("Trying to remove an inexistant observer")
log.error(_("INTERNAL ERROR: ") + err_msg)
err_msg = _(u"Trying to remove an inexistant observer")
log.error(_(u"INTERNAL ERROR: ") + err_msg)
raise MaildirError(err_msg)
self.__observed[(profile, boxname)][signal].remove(callback)
def emitSignal(self, profile, boxname, signal_name):
"""Emit the signal to observer"""
log.debug('emitSignal %s %s %s' % (profile, boxname, signal_name))
log.debug(u'emitSignal %s %s %s' % (profile, boxname, signal_name))
try:
for observer_cb in self.__observed[(profile, boxname)][signal_name]:
observer_cb()
@ -336,7 +336,7 @@ class MailboxUser(object):
@param profile: real profile (ie not a profile_key)
THIS OBJECT MUST NOT BE USED DIRECTLY: use MaildirBox.accessMessageBox instead"""
if _maildir._checkBoxReference(name, profile):
log.error("INTERNAL ERROR: MailboxUser MUST NOT be instancied directly")
log.error(u"INTERNAL ERROR: MailboxUser MUST NOT be instancied directly")
raise MaildirError('double MailboxUser instanciation')
if name != "INBOX":
raise NotImplementedError
@ -354,7 +354,7 @@ class MailboxUser(object):
self.__uid_table_update()
if observer:
log.debug("adding observer for %s (%s)" % (name, profile))
log.debug(u"adding observer for %s (%s)" % (name, profile))
self.maildir.addObserver(observer, profile, name, "NEW_MESSAGE")
def __uid_table_update(self):
@ -367,7 +367,7 @@ class MailboxUser(object):
def __del__(self):
if self.observer:
log.debug("removing observer for %s" % self.name)
log.debug(u"removing observer for %s" % self.name)
self._maildir.removeObserver(self.observer, self.name, "NEW_MESSAGE")
self.maildir._removeBoxAccess(self.name, self, profile=self.profile)

View file

@ -181,9 +181,9 @@ class Quiz(object):
"""Called when a player give an answer"""
profile = self.host.memory.getProfileName(profile_key)
if not profile:
log.error(_("profile %s is unknown") % profile_key)
log.error(_(u"profile %s is unknown") % profile_key)
return
log.debug('new player answer (%(profile)s): %(answer)s' % {'profile': profile, 'answer': answer})
log.debug(u'new player answer (%(profile)s): %(answer)s' % {'profile': profile, 'answer': answer})
mess = self.createGameElt(jid.JID(referee))
answer_elt = mess.firstChildElement().addElement('player_answer')
answer_elt['player'] = player
@ -281,7 +281,7 @@ Attention, tu es prêt ?""")}
status = self.games[room_jid]['status']
nb_players = len(self.games[room_jid]['players'])
status[player] = 'ready'
log.debug(_('Player %(player)s is ready to start [status: %(status)s]') % {'player': player, 'status': status})
log.debug(_(u'Player %(player)s is ready to start [status: %(status)s]') % {'player': player, 'status': status})
if status.values().count('ready') == nb_players: # everybody is ready, we can start the game
self.newGame(room_jid, profile)
@ -329,4 +329,4 @@ Attention, tu es prêt ?""")}
self.host.bridge.quizGameTimerRestarted(room_jid.userhost(), int(elt['time_left']), profile)
else:
log.error(_('Unmanaged game element: %s') % elt.name)
log.error(_(u'Unmanaged game element: %s') % elt.name)

View file

@ -136,7 +136,7 @@ class Radiocol(object):
# ==> unlink done the Q&D way with the same host trick (see above)
radio_data = self.games[room_jid]
if len(radio_data['players']) == 0:
log.debug(_('No more participants in the radiocol: cleaning data'))
log.debug(_(u'No more participants in the radiocol: cleaning data'))
radio_data['queue'] = []
for filename in radio_data['to_delete']:
self.deleteFile(filename, radio_data)
@ -172,14 +172,14 @@ class Radiocol(object):
try:
file_to_delete = radio_data['to_delete'][filename]
except KeyError:
log.error(_("INTERNAL ERROR: can't find full path of the song to delete"))
log.error(_(u"INTERNAL ERROR: can't find full path of the song to delete"))
return False
else:
file_to_delete = filename
try:
unlink(file_to_delete)
except OSError:
log.error(_("INTERNAL ERROR: can't find %s on the file system" % file_to_delete))
log.error(_(u"INTERNAL ERROR: can't find %s on the file system" % file_to_delete))
return False
return True
@ -242,7 +242,7 @@ class Radiocol(object):
# songs in queue. We can now start the party :)
self.playNext(room_jid, profile)
else:
log.error(_('Unmanaged game element: %s') % elt.name)
log.error(_(u'Unmanaged game element: %s') % elt.name)
def getSyncDataForPlayer(self, room_jid, nick):
game_data = self.games[room_jid]

View file

@ -205,7 +205,7 @@ class RoomGame(object):
break
if not auth and (verbose or _DEBUG):
log.debug(_("%(user)s not allowed to join the game %(game)s in %(room)s") % {'user': user_jid.userhost() or nick, 'game': self.name, 'room': room_jid.userhost()})
log.debug(_(u"%(user)s not allowed to join the game %(game)s in %(room)s") % {'user': user_jid.userhost() or nick, 'game': self.name, 'room': room_jid.userhost()})
return auth
def _updatePlayers(self, room_jid, nicks, sync, profile):
@ -341,7 +341,7 @@ class RoomGame(object):
elif self.invite_mode == self.FROM_PLAYERS:
auth = self.isPlayer(room_jid, nick)
if not auth and (verbose or _DEBUG):
log.debug(_("%(user)s not allowed to invite for the game %(game)s in %(room)s") % {'user': nick, 'game': self.name, 'room': room_jid.userhost()})
log.debug(_(u"%(user)s not allowed to invite for the game %(game)s in %(room)s") % {'user': nick, 'game': self.name, 'room': room_jid.userhost()})
return auth
def isReferee(self, room_jid, nick):
@ -387,7 +387,7 @@ class RoomGame(object):
(nicks, missing) = self.host.plugins["XEP-0045"].getRoomNicksOfUsers(room, other_players, secure=False)
result = (len(nicks) == len(other_players), nicks, missing)
if not result[0] and (verbose or _DEBUG):
log.debug(_("Still waiting for %(users)s before starting the game %(game)s in %(room)s") % {'users': result[2], 'game': self.name, 'room': room.occupantJID.userhost()})
log.debug(_(u"Still waiting for %(users)s before starting the game %(game)s in %(room)s") % {'users': result[2], 'game': self.name, 'room': room.occupantJID.userhost()})
return result
def getUniqueName(self, muc_service=None, profile_key=C.PROF_KEY_NONE):
@ -413,7 +413,7 @@ class RoomGame(object):
@param room_jid (jid.JID): JID of the room, or None to generate a unique name
@param profile_key (unicode): %(doc_profile_key)s
"""
log.debug(_('Preparing room for %s game') % self.name)
log.debug(_(u'Preparing room for %s game') % self.name)
profile = self.host.memory.getProfileName(profile_key)
if not profile:
log.error(_("Unknown profile"))
@ -456,7 +456,7 @@ class RoomGame(object):
# considering the last batch of invitations
batch = len(self.invitations[room_jid]) - 1
if batch < 0:
log.error("Invitations from %s to play %s in %s have been lost!" % (profile_nick, self.name, room_jid.userhost()))
log.error(u"Invitations from %s to play %s in %s have been lost!" % (profile_nick, self.name, room_jid.userhost()))
return True
other_players = self.invitations[room_jid][batch][1]
(auth, nicks, dummy) = self._checkWaitAuth(room, other_players)
@ -510,15 +510,15 @@ class RoomGame(object):
"""
user_nick = self.host.plugins["XEP-0045"].getRoomNick(room_jid, profile)
if not user_nick:
log.error('Internal error: profile %s has not joined the room %s' % (profile, room_jid.userhost()))
log.error(u'Internal error: profile %s has not joined the room %s' % (profile, room_jid.userhost()))
return False, False
if self._gameExists(room_jid):
is_referee = self.isReferee(room_jid, user_nick)
if self._gameExists(room_jid, started=True):
log.warning(_("%(game)s game already created in room %(room)s") % {'game': self.name, 'room': room_jid.userhost()})
log.warning(_(u"%(game)s game already created in room %(room)s") % {'game': self.name, 'room': room_jid.userhost()})
return False, is_referee
elif not is_referee:
log.warning(_("%(game)s game in room %(room)s can only be created by %(user)s") % {'game': self.name, 'room': room_jid.userhost(), 'user': user_nick})
log.warning(_(u"%(game)s game in room %(room)s can only be created by %(user)s") % {'game': self.name, 'room': room_jid.userhost(), 'user': user_nick})
return False, False
else:
self._initGame(room_jid, user_nick)
@ -536,10 +536,10 @@ class RoomGame(object):
@param nicks (list[unicode]): list of players nicks in the room (referee included, in first position)
@param profile_key (unicode): %(doc_profile_key)s
"""
log.debug(_("Creating %(game)s game in room %(room)s") % {'game': self.name, 'room': room_jid})
log.debug(_(u"Creating %(game)s game in room %(room)s") % {'game': self.name, 'room': room_jid})
profile = self.host.memory.getProfileName(profile_key)
if not profile:
log.error(_("profile %s is unknown") % profile_key)
log.error(_(u"profile %s is unknown") % profile_key)
return
(create, sync) = self._checkCreateGameAndInit(room_jid, profile)
if nicks is None:
@ -568,9 +568,9 @@ class RoomGame(object):
"""
profile = self.host.memory.getProfileName(profile_key)
if not profile:
log.error(_("profile %s is unknown") % profile_key)
log.error(_(u"profile %s is unknown") % profile_key)
return
log.debug('new player ready: %s' % profile)
log.debug(u'new player ready: %s' % profile)
# TODO: we probably need to add the game and room names in the sent message
self.send(referee_jid, 'player_ready', {'player': player_nick}, profile=profile)
@ -583,7 +583,7 @@ class RoomGame(object):
- msg_elts: dict to map each user to his specific initialization message
@param profile
"""
log.debug(_('new round for %s game') % self.name)
log.debug(_(u'new round for %s game') % self.name)
game_data = self.games[room_jid]
players = game_data['players']
players_data = game_data['players_data']

View file

@ -91,7 +91,7 @@ class SatSmtpMessage(object):
subject=mail['subject'].decode('utf-8', 'replace'), mess_type='normal', profile_key=self.profile)
except:
exc_type, exc_value, exc_traceback = sys.exc_info()
log.error(_("Can't send message: %s") % exc_value) # The email is invalid or incorreclty parsed
log.error(_(u"Can't send message: %s") % exc_value) # The email is invalid or incorreclty parsed
return defer.fail()
self.message = None
return defer.succeed(None)
@ -200,7 +200,7 @@ class SmtpServerFactory(smtp.SMTPFactory):
smtp.SMTPFactory.startedConnecting(self, connector)
def clientConnectionLost(self, connector, reason):
log.debug(_("SMTP server connection lost (reason: %s)"), reason)
log.debug(_(u"SMTP server connection lost (reason: %s)"), reason)
smtp.SMTPFactory.clientConnectionLost(self, connector, reason)
def buildProtocol(self, addr):

View file

@ -198,7 +198,7 @@ class Tarot(object):
pl_waiting = players_data[player]['wait_for_low']
played.remove(card)
players_data[pl_waiting]['levees'].append(card)
log.debug(_('Player %(excuse_owner)s give %(card_waited)s to %(player_waiting)s for Excuse compensation') % {"excuse_owner": player, "card_waited": card, "player_waiting": pl_waiting})
log.debug(_(u'Player %(excuse_owner)s give %(card_waited)s to %(player_waiting)s for Excuse compensation') % {"excuse_owner": player, "card_waited": card, "player_waiting": pl_waiting})
return
return
@ -229,12 +229,12 @@ class Tarot(object):
low_card = owner_levees[card_idx]
del owner_levees[card_idx]
players_data[winner]['levees'].append(low_card)
log.debug(_('Player %(excuse_owner)s give %(card_waited)s to %(player_waiting)s for Excuse compensation') % {"excuse_owner": excuse_player, "card_waited": low_card, "player_waiting": winner})
log.debug(_(u'Player %(excuse_owner)s give %(card_waited)s to %(player_waiting)s for Excuse compensation') % {"excuse_owner": excuse_player, "card_waited": low_card, "player_waiting": winner})
break
if not low_card: # The player has no low card yet
# TODO: manage case when player never win a trick with low card
players_data[excuse_player]['wait_for_low'] = winner
log.debug(_("%(excuse_owner)s keep the Excuse but has not card to give, %(winner)s is waiting for one") % {'excuse_owner': excuse_player, 'winner': winner})
log.debug(_(u"%(excuse_owner)s keep the Excuse but has not card to give, %(winner)s is waiting for one") % {'excuse_owner': excuse_player, 'winner': winner})
def __draw_game(self, game_data):
"""The game is draw, no score change
@ -244,7 +244,7 @@ class Tarot(object):
scores_str = _('Draw game')
scores_str += '\n'
for player in game_data['players']:
scores_str += _("\n--\n%(player)s:\nscore for this game ==> %(score_game)i\ntotal score ==> %(total_score)i") % {'player': player, 'score_game': 0, 'total_score': players_data[player]['score']}
scores_str += _(u"\n--\n%(player)s:\nscore for this game ==> %(score_game)i\ntotal score ==> %(total_score)i") % {'player': player, 'score_game': 0, 'total_score': players_data[player]['score']}
log.debug(scores_str)
return (scores_str, [], [])
@ -313,10 +313,10 @@ class Tarot(object):
else:
loosers.append(player)
scores_str = _('The attacker (%(attaquant)s) makes %(points)i and needs to make %(point_limit)i (%(nb_bouts)s oulder%(plural)s%(separator)s%(bouts)s): (s)he %(victory)s') % {'attaquant': game_data['attaquant'], 'points': score, 'point_limit': point_limit, 'nb_bouts': nb_bouts, 'plural': 's' if nb_bouts > 1 else '', 'separator': ': ' if nb_bouts != 0 else '', 'bouts': ','.join(map(str, bouts)), 'victory': 'wins' if victory else 'looses'}
scores_str = _(u'The attacker (%(attaquant)s) makes %(points)i and needs to make %(point_limit)i (%(nb_bouts)s oulder%(plural)s%(separator)s%(bouts)s): (s)he %(victory)s') % {'attaquant': game_data['attaquant'], 'points': score, 'point_limit': point_limit, 'nb_bouts': nb_bouts, 'plural': 's' if nb_bouts > 1 else '', 'separator': ': ' if nb_bouts != 0 else '', 'bouts': ','.join(map(str, bouts)), 'victory': 'wins' if victory else 'looses'}
scores_str += '\n'
for player in game_data['players']:
scores_str += _("\n--\n%(player)s:\nscore for this game ==> %(score_game)i\ntotal score ==> %(total_score)i") % {'player': player, 'score_game': player_score[player], 'total_score': players_data[player]['score']}
scores_str += _(u"\n--\n%(player)s:\nscore for this game ==> %(score_game)i\ntotal score ==> %(total_score)i") % {'player': player, 'score_game': player_score[player], 'total_score': players_data[player]['score']}
log.debug(scores_str)
return (scores_str, winners, loosers)
@ -402,7 +402,7 @@ class Tarot(object):
player = self.host.plugins["XEP-0045"].getRoomNick(room_jid, profile)
data = xml_tools.XMLUIResult2DataFormResult(raw_data)
contrat = data['contrat']
log.debug(_('contrat [%(contrat)s] choosed by %(profile)s') % {'contrat': contrat, 'profile': profile})
log.debug(_(u'contrat [%(contrat)s] choosed by %(profile)s') % {'contrat': contrat, 'profile': profile})
d = self.send(referee_jid, ('', 'contrat_choosed'), {'player': player}, content=contrat, profile=profile)
d.addCallback(lambda ignore: {})
del self._sessions[raw_data["session_id"]]
@ -435,9 +435,9 @@ class Tarot(object):
"""
profile = self.host.memory.getProfileName(profile_key)
if not profile:
log.error(_("profile %s is unknown") % profile_key)
log.error(_(u"profile %s is unknown") % profile_key)
return
log.debug(_('Cards played by %(profile)s: [%(cards)s]') % {'profile': profile, 'cards': cards})
log.debug(_(u'Cards played by %(profile)s: [%(cards)s]') % {'profile': profile, 'cards': cards})
elem = self.__card_list_to_xml(TarotCard.from_tuples(cards), 'cards_played')
self.send(jid.JID(referee), elem, {'player': player}, profile=profile)
@ -503,7 +503,7 @@ class Tarot(object):
status = self.games[room_jid]['status']
nb_players = len(self.games[room_jid]['players'])
status[player] = 'ready'
log.debug(_('Player %(player)s is ready to start [status: %(status)s]') % {'player': player, 'status': status})
log.debug(_(u'Player %(player)s is ready to start [status: %(status)s]') % {'player': player, 'status': status})
if status.values().count('ready') == nb_players: # everybody is ready, we can start the game
self.newRound(room_jid, profile)
@ -545,7 +545,7 @@ class Tarot(object):
for player in game_data['players']:
game_data['status'][player] = "init"
return
log.debug(_("%(player)s win the bid with %(contrat)s") % {'player': best_contrat[0], 'contrat': best_contrat[1]})
log.debug(_(u"%(player)s win the bid with %(contrat)s") % {'player': best_contrat[0], 'contrat': best_contrat[1]})
game_data['contrat'] = best_contrat[1]
if game_data['contrat'] == "Garde Sans" or game_data['contrat'] == "Garde Contre":
@ -617,7 +617,7 @@ class Tarot(object):
if all(played):
# everybody has played
winner = self.__winner(game_data)
log.debug(_('The winner of this trick is %s') % winner)
log.debug(_(u'The winner of this trick is %s') % winner)
# the winner win the trick
self.__excuse_hack(game_data, played, winner)
players_data[elt['player']]['levees'].extend(played)
@ -663,9 +663,9 @@ class Tarot(object):
invalid_cards = self.__xml_to_list(elt.elements(name='invalid', uri=NS_CG).next())
self.host.bridge.tarotGameInvalidCards(room_jid.userhost(), elt['phase'], played_cards, invalid_cards, profile)
else:
log.error(_('Unmanaged error type: %s') % elt['type'])
log.error(_(u'Unmanaged error type: %s') % elt['type'])
else:
log.error(_('Unmanaged card game element: %s') % elt.name)
log.error(_(u'Unmanaged card game element: %s') % elt.name)
def getSyncDataForPlayer(self, room_jid, nick):
return []

View file

@ -138,7 +138,7 @@ class TextCommands(object):
if attr.startswith('cmd_'):
cmd = getattr(instance, attr)
if not callable(cmd):
log.warning(_("Skipping not callable [%s] attribute") % attr)
log.warning(_(u"Skipping not callable [%s] attribute") % attr)
continue
cmd_name = attr[4:]
if not cmd_name:
@ -148,7 +148,7 @@ class TextCommands(object):
while (cmd_name + str(suff)) in self._commands:
suff+=1
new_name = cmd_name + str(suff)
log.warning(_("Conflict for command [%(old_name)s], renaming it to [%(new_name)s]") % {'old_name': cmd_name, 'new_name': new_name})
log.warning(_(u"Conflict for command [%(old_name)s], renaming it to [%(new_name)s]") % {'old_name': cmd_name, 'new_name': new_name})
cmd_name = new_name
self._commands[cmd_name] = cmd_data = OrderedDict({'callback':cmd}) # We use an Ordered dict to keep documenation order
cmd_data.update(self._parseDocString(cmd, cmd_name))

View file

@ -155,12 +155,12 @@ class Account(potr.context.Account):
trust_data = self.client.otr_data.get('trust', {})
for jid_, jid_data in trust_data.iteritems():
for fingerprint, trust_level in jid_data.iteritems():
log.debug('setting trust for {jid}: [{fingerprint}] = "{trust_level}"'.format(jid=jid_, fingerprint=fingerprint, trust_level=trust_level))
log.debug(u'setting trust for {jid}: [{fingerprint}] = "{trust_level}"'.format(jid=jid_, fingerprint=fingerprint, trust_level=trust_level))
self.trusts.setdefault(jid.JID(jid_), {})[fingerprint] = trust_level
def saveTrusts(self):
log.debug("saving trusts for {profile}".format(profile=self.client.profile))
log.debug("trusts = {}".format(self.client.otr_data['trust']))
log.debug(u"saving trusts for {profile}".format(profile=self.client.profile))
log.debug(u"trusts = {}".format(self.client.otr_data['trust']))
self.client.otr_data.force('trust')
def setTrust(self, other_jid, fingerprint, trustLevel):
@ -189,7 +189,7 @@ class ContextManager(object):
def getContextForUser(self, other):
log.debug(u"getContextForUser [%s]" % other)
if not other.resource:
log.warning("getContextForUser called with a bare jid: %s" % other.full())
log.warning(u"getContextForUser called with a bare jid: %s" % other.full())
return self.startContext(other)

View file

@ -69,7 +69,7 @@ class XEP_0020(object):
values = form.fields[field].values
result[field] = values[0] if values else None
if len(values) > 1:
log.warning(_("More than one value choosed for %s, keeping the first one") % field)
log.warning(_(u"More than one value choosed for %s, keeping the first one") % field)
return result
def negociate(self, feature_elt, form_type, negociable_values):

View file

@ -88,8 +88,8 @@ class XEP_0033(object):
raise failure.Failure(exceptions.CancelError())
if mess_data["to"] not in entities:
expected = _(' or ').join([entity.userhost() for entity in entities])
log.warning(_("Stanzas using XEP-0033 should be addressed to %(expected)s, not %(current)s!") % {'expected': expected, 'current': mess_data["to"]})
log.warning(_("TODO: addressing has been fixed by the backend... fix it in the frontend!"))
log.warning(_(u"Stanzas using XEP-0033 should be addressed to %(expected)s, not %(current)s!") % {'expected': expected, 'current': mess_data["to"]})
log.warning(_(u"TODO: addressing has been fixed by the backend... fix it in the frontend!"))
mess_data["to"] = list(entities)[0].userhostJID()
element = mess_data['xml'].addElement('addresses', NS_ADDRESS)
entries = [entry.split(':') for entry in mess_data['extra']['address'].split('\n') if entry != '']

View file

@ -106,7 +106,7 @@ class XEP_0045(object):
@param profile: profile to check
@return: True if the profile is connected and has used the MUC feature, else False"""
if not profile or profile not in self.clients or not self.host.isConnected(profile):
log.error(_('Unknown or disconnected profile (%s)') % profile)
log.error(_(u'Unknown or disconnected profile (%s)') % profile)
if profile in self.clients:
del self.clients[profile]
return False
@ -138,7 +138,7 @@ class XEP_0045(object):
# and send the signal only when the room is unlocked
# a proper configuration management should be done
print "room locked !"
self.clients[profile].configure(room.roomJID, {}).addCallbacks(_sendBridgeSignal, lambda x: log.error(_('Error while configuring the room')))
self.clients[profile].configure(room.roomJID, {}).addCallbacks(_sendBridgeSignal, lambda x: log.error(_(u'Error while configuring the room')))
else:
_sendBridgeSignal()
return room
@ -359,9 +359,9 @@ class XEP_0045(object):
if not self.checkClient(profile):
return _errDeferred()
if room_jid in self.clients[profile].joined_rooms:
log.warning(_('%(profile)s is already in room %(room_jid)s') % {'profile': profile, 'room_jid': room_jid.userhost()})
log.warning(_(u'%(profile)s is already in room %(room_jid)s') % {'profile': profile, 'room_jid': room_jid.userhost()})
return _errDeferred()
log.info(_("[%(profile)s] is joining room %(room)s with nick %(nick)s") % {'profile': profile, 'room': room_jid.userhost(), 'nick': nick})
log.info(_(u"[%(profile)s] is joining room %(room)s with nick %(nick)s") % {'profile': profile, 'room': room_jid.userhost(), 'nick': nick})
if "history" in options:
history_limit = int(options["history"])
@ -709,7 +709,7 @@ class SatMUCClient (muc.MUCClient):
if user.nick in self.__changing_nicks:
self.__changing_nicks.remove(user.nick)
else:
log.debug(_("user %(nick)s has joined room (%(room_id)s)") % {'nick': user.nick, 'room_id': room.occupantJID.userhost()})
log.debug(_(u"user %(nick)s has joined room (%(room_id)s)") % {'nick': user.nick, 'room_id': room.occupantJID.userhost()})
if not self.host.trigger.point("MUC user joined", room, user, self.parent.profile):
return
user_data = {'entity': user.entity.full() if user.entity else '', 'affiliation': user.affiliation, 'role': user.role}
@ -721,12 +721,12 @@ class SatMUCClient (muc.MUCClient):
if user.nick == room.nick:
# we left the room
room_jid_s = room.roomJID.userhost()
log.info(_("Room [%(room)s] left (%(profile)s))") % {"room": room_jid_s,
log.info(_(u"Room [%(room)s] left (%(profile)s))") % {"room": room_jid_s,
"profile": self.parent.profile})
self.host.memory.delEntityCache(room.roomJID, profile_key=self.parent.profile)
self.host.bridge.roomLeft(room.roomJID.userhost(), self.parent.profile)
else:
log.debug(_("user %(nick)s left room (%(room_id)s)") % {'nick': user.nick, 'room_id': room.occupantJID.userhost()})
log.debug(_(u"user %(nick)s left room (%(room_id)s)") % {'nick': user.nick, 'room_id': room.occupantJID.userhost()})
user_data = {'entity': user.entity.full() if user.entity else '', 'affiliation': user.affiliation, 'role': user.role}
self.host.bridge.roomUserLeft(room.roomJID.userhost(), user.nick, user_data, self.parent.profile)
@ -737,15 +737,15 @@ class SatMUCClient (muc.MUCClient):
self.host.bridge.presenceUpdate(room.roomJID.userhost() + '/' + user.nick, show or '', 0, {'default': status or ''}, self.parent.profile)
def receivedGroupChat(self, room, user, body):
log.debug('receivedGroupChat: room=%s user=%s body=%s' % (room.roomJID.full(), user, body))
log.debug(u'receivedGroupChat: room=%s user=%s body=%s' % (room.roomJID.full(), user, body))
def receivedHistory(self, room, user, message):
# http://xmpp.org/extensions/xep-0045.html#enter-history
# log.debug('receivedHistory: room=%s user=%s body=%s' % (room.roomJID.full(), user, message))
# log.debug(u'receivedHistory: room=%s user=%s body=%s' % (room.roomJID.full(), user, message))
pass
def receivedSubject(self, room, user, subject):
# http://xmpp.org/extensions/xep-0045.html#enter-subject
log.debug(_("New subject for room (%(room_id)s): %(subject)s") % {'room_id': room.roomJID.full(), 'subject': subject})
log.debug(_(u"New subject for room (%(room_id)s): %(subject)s") % {'room_id': room.roomJID.full(), 'subject': subject})
self.rec_subjects[room.roomJID.userhost()] = (room.roomJID.userhost(), subject)
self.host.bridge.roomNewSubject(room.roomJID.userhost(), subject, self.parent.profile)

View file

@ -143,11 +143,11 @@ class XEP_0047(object):
sid = open_elt.getAttribute('sid')
stanza = open_elt.getAttribute('stanza', 'iq')
if not sid or not block_size or int(block_size) > 65535:
log.warning(_("malformed IBB transfer: %s" % IQ['id']))
log.warning(_(u"malformed IBB transfer: %s" % IQ['id']))
self.sendNotAcceptableError(IQ['id'], IQ['from'], client.xmlstream)
return
if not sid in client.xep_0047_current_stream:
log.warning(_("Ignoring unexpected IBB transfer: %s" % sid))
log.warning(_(u"Ignoring unexpected IBB transfer: %s" % sid))
self.sendNotAcceptableError(IQ['id'], IQ['from'], client.xmlstream)
return
if client.xep_0047_current_stream[sid]["from"] != jid.JID(IQ['from']):

View file

@ -221,7 +221,7 @@ class XEP_0048(object):
d = self.host.plugins['XEP-0045'].join(room_jid, nick, {}, profile_key=profile)
def join_eb(failure):
log.warning("Error while trying to join room: %s" % failure)
log.warning(u"Error while trying to join room: %s" % failure)
# FIXME: failure are badly managed in plugin XEP-0045. Plugin XEP-0045 need to be fixed before managing errors correctly here
return {}
d.addCallbacks(lambda dummy: {}, join_eb)

View file

@ -107,7 +107,7 @@ class AdHocCommand(XMPPHandler):
try:
allowed.update(self.client.roster.getJidsFromGroup(group))
except exceptions.UnknownGroupError:
log.warning(_("The groups [%(group)s] is unknown for profile [%(profile)s])" % {'group':group, 'profile':self.client.profile}))
log.warning(_(u"The groups [%(group)s] is unknown for profile [%(profile)s])" % {'group':group, 'profile':self.client.profile}))
if requestor.userhostJID() in allowed:
return True
return False
@ -254,7 +254,7 @@ class XEP_0050(object):
return C.XMLUI_DATA_LVL_WARNING
else:
if type_ != 'info':
log.warning(_("Invalid note type [%s], using info") % type_)
log.warning(_(u"Invalid note type [%s], using info") % type_)
return C.XMLUI_DATA_LVL_INFO
def _mergeNotes(self, notes):

Some files were not shown because too many files have changed in this diff Show more