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
46 changed files with 272 additions and 271 deletions

View file

@ -348,7 +348,7 @@ class PrimitivusApp(QuickApp, InputHistory):
try:
config.applyConfig(self)
except Exception as e:
log.error("configuration error: {}".format(e))
log.error(u"configuration error: {}".format(e))
popup = sat_widgets.Alert(_("Configuration Error"), _("Something went wrong while reading the configuration, please check :messages"), ok_cb=self.removePopUp)
if self.options.profile:
self._early_popup = popup

View file

@ -81,7 +81,7 @@ class ProfileManager(object):
self.host.bridge.getEntitiesData([], ProfileManager.cache_keys_to_get, profile=self.profile, callback=self._plug_profile_gotCachedValues, errback=self._plug_profile_failedCachedValues)
def _plug_profile_failedCachedValues(self, failure):
log.error("Couldn't get cached values: {}".format(failure))
log.error(u"Couldn't get cached values: {}".format(failure))
self._plug_profile_gotCachedValues({})
def _plug_profile_gotCachedValues(self, cached_values):
@ -139,7 +139,7 @@ class ProfileManager(object):
priority = presences[contact][res][1]
statuses = presences[contact][res][2]
self.host.presenceUpdateHandler(jabber_id, show, priority, statuses, self.profile)
self.host.bridge.getEntityData(contact, ['avatar', 'nick'], self.profile, callback=lambda data, contact=contact: gotEntityData(data, contact), errback=lambda failure, contact=contact: log.debug("No cache data for {}".format(contact)))
self.host.bridge.getEntityData(contact, ['avatar', 'nick'], self.profile, callback=lambda data, contact=contact: gotEntityData(data, contact), errback=lambda failure, contact=contact: log.debug(u"No cache data for {}".format(contact)))
#Finaly, we get the waiting confirmation requests
self.bridge.getWaitingConf(self.profile, callback=self._plug_profile_gotWaitingConf)
@ -510,7 +510,7 @@ class QuickApp(object):
def presenceUpdateHandler(self, entity_s, show, priority, statuses, profile):
log.debug(_("presence update for %(entity)s (show=%(show)s, priority=%(priority)s, statuses=%(statuses)s) [profile:%(profile)s]")
log.debug(_(u"presence update for %(entity)s (show=%(show)s, priority=%(priority)s, statuses=%(statuses)s) [profile:%(profile)s]")
% {'entity': entity_s, C.PRESENCE_SHOW: show, C.PRESENCE_PRIORITY: priority, C.PRESENCE_STATUSES: statuses, 'profile': profile})
entity = jid.JID(entity_s)
@ -529,7 +529,7 @@ class QuickApp(object):
def roomJoinedHandler(self, room_jid_s, room_nicks, user_nick, profile):
"""Called when a MUC room is joined"""
log.debug("Room [%(room_jid)s] joined by %(profile)s, users presents:%(users)s" % {'room_jid': room_jid_s, 'profile': profile, 'users': room_nicks})
log.debug(u"Room [%(room_jid)s] joined by %(profile)s, users presents:%(users)s" % {'room_jid': room_jid_s, 'profile': profile, 'users': room_nicks})
room_jid = jid.JID(room_jid_s)
chat_widget = self.widgets.getOrCreateWidget(quick_chat.QuickChat, room_jid, type_=C.CHAT_GROUP, profile=profile)
chat_widget.setUserNick(unicode(user_nick))
@ -538,7 +538,7 @@ class QuickApp(object):
def roomLeftHandler(self, room_jid_s, profile):
"""Called when a MUC room is left"""
log.debug("Room [%(room_jid)s] left by %(profile)s" % {'room_jid': room_jid_s, 'profile': profile})
log.debug(u"Room [%(room_jid)s] left by %(profile)s" % {'room_jid': room_jid_s, 'profile': profile})
room_jid = jid.JID(room_jid_s)
chat_widget = self.widgets.getWidget(quick_chat.QuickChat, room_jid, profile)
if chat_widget:
@ -550,28 +550,28 @@ class QuickApp(object):
room_jid = jid.JID(room_jid_s)
chat_widget = self.widgets.getOrCreateWidget(quick_chat.QuickChat, room_jid, type_=C.CHAT_GROUP, profile=profile)
chat_widget.addUser(user_nick)
log.debug("user [%(user_nick)s] joined room [%(room_jid)s]" % {'user_nick': user_nick, 'room_jid': room_jid})
log.debug(u"user [%(user_nick)s] joined room [%(room_jid)s]" % {'user_nick': user_nick, 'room_jid': room_jid})
def roomUserLeftHandler(self, room_jid_s, user_nick, user_data, profile):
"""Called when an user joined a MUC room"""
room_jid = jid.JID(room_jid_s)
chat_widget = self.widgets.getOrCreateWidget(quick_chat.QuickChat, room_jid, type_=C.CHAT_GROUP, profile=profile)
chat_widget.removeUser(user_nick)
log.debug("user [%(user_nick)s] left room [%(room_jid)s]" % {'user_nick': user_nick, 'room_jid': room_jid})
log.debug(u"user [%(user_nick)s] left room [%(room_jid)s]" % {'user_nick': user_nick, 'room_jid': room_jid})
def roomUserChangedNickHandler(self, room_jid_s, old_nick, new_nick, profile):
"""Called when an user joined a MUC room"""
room_jid = jid.JID(room_jid_s)
chat_widget = self.widgets.getOrCreateWidget(quick_chat.QuickChat, room_jid, type_=C.CHAT_GROUP, profile=profile)
chat_widget.changeUserNick(old_nick, new_nick)
log.debug("user [%(old_nick)s] is now known as [%(new_nick)s] in room [%(room_jid)s]" % {'old_nick': old_nick, 'new_nick': new_nick, 'room_jid': room_jid})
log.debug(u"user [%(old_nick)s] is now known as [%(new_nick)s] in room [%(room_jid)s]" % {'old_nick': old_nick, 'new_nick': new_nick, 'room_jid': room_jid})
def roomNewSubjectHandler(self, room_jid_s, subject, profile):
"""Called when subject of MUC room change"""
room_jid = jid.JID(room_jid_s)
chat_widget = self.widgets.getOrCreateWidget(quick_chat.QuickChat, room_jid, type_=C.CHAT_GROUP, profile=profile)
chat_widget.setSubject(subject)
log.debug("new subject for room [%(room_jid)s]: %(subject)s" % {'room_jid': room_jid, "subject": subject})
log.debug(u"new subject for room [%(room_jid)s]: %(subject)s" % {'room_jid': room_jid, "subject": subject})
def chatStateReceivedHandler(self, from_jid_s, state, profile):
"""Called when a new chat state (XEP-0085) is received.
@ -630,9 +630,9 @@ class QuickApp(object):
pass #FIXME
def paramUpdateHandler(self, name, value, namespace, profile):
log.debug(_("param update: [%(namespace)s] %(name)s = %(value)s") % {'namespace': namespace, 'name': name, 'value': value})
log.debug(_(u"param update: [%(namespace)s] %(name)s = %(value)s") % {'namespace': namespace, 'name': name, 'value': value})
if (namespace, name) == ("Connection", "JabberID"):
log.debug(_("Changing JID to %s") % value)
log.debug(_(u"Changing JID to %s") % value)
self.profiles[profile].whoami = jid.JID(value)
elif (namespace, name) == ("Misc", "Watched"):
self.profiles[profile]['watched'] = value.split()

View file

@ -363,7 +363,7 @@ class QuickContactList(QuickWidget):
try:
groups = self._cache[entity_bare].get(C.CONTACT_GROUPS, set())
except KeyError:
log.warning(_("Trying to delete an unknow entity [{}]").format(entity))
log.warning(_(u"Trying to delete an unknow entity [{}]").format(entity))
if in_roster:
self._roster.remove(entity_bare)
del self._cache[entity_bare]
@ -397,7 +397,7 @@ class QuickContactList(QuickWidget):
try:
del cache[C.CONTACT_RESOURCES][entity.resource]
except KeyError:
log.error("Presence unavailable received for an unknown resource [{}]".format(entity))
log.error(u"Presence unavailable received for an unknown resource [{}]".format(entity))
if not cache[C.CONTACT_RESOURCES]:
cache[C.CONTACT_MAIN_RESOURCE] = None
else:
@ -432,7 +432,7 @@ class QuickContactList(QuickWidget):
@param entity(jid.JID): entity to select (resource is significant)
"""
log.debug("select %s" % entity)
log.debug(u"select %s" % entity)
self._selected.add(entity)
self.update()

View file

@ -205,7 +205,7 @@ class MenuContainer(MenuBase):
raise KeyError(item)
def getOrCreate(self, item):
log.debug("MenuContainer getOrCreate: item=%s name=%s\nlist=%s" % (item, item.canonical, self._items.keys()))
log.debug(u"MenuContainer getOrCreate: item=%s name=%s\nlist=%s" % (item, item.canonical, self._items.keys()))
try:
return self[item]
except KeyError:

View file

@ -178,11 +178,11 @@ class QuickProfileManager(object):
if login != self.current.login and self.current.login is not None:
self.current.login = login
self.host.bridge.setParam("JabberID", login, "Connection", profile_key=self.current.profile)
log.info("login updated for profile [{}]".format(self.current.profile))
log.info(u"login updated for profile [{}]".format(self.current.profile))
if password != self.current.password and self.current.password is not None:
self.current.password = password
self.host.bridge.setParam("Password", password, "Connection", profile_key=self.current.profile)
log.info("password updated for profile [{}]".format(self.current.profile))
log.info(u"password updated for profile [{}]".format(self.current.profile))
## graphic updates (should probably be overriden in frontends) ##

View file

@ -162,7 +162,7 @@ class SAT(service.Service):
try:
__import__(plugin_path)
except ImportError as e:
log.error(_("Can't import plugin [%(path)s]: %(error)s") % {'path': plugin_path, 'error':e})
log.error(_(u"Can't import plugin [%(path)s]: %(error)s") % {'path': plugin_path, 'error':e})
continue
mod = sys.modules[plugin_path]
plugin_info = mod.PLUGIN_INFO
@ -180,27 +180,27 @@ class SAT(service.Service):
"""
if import_name in self.plugins:
log.debug('Plugin [%s] already imported, passing' % import_name)
log.debug(u'Plugin [%s] already imported, passing' % import_name)
return
if not import_name:
import_name, (plugin_path, mod, plugin_info) = plugins_to_import.popitem()
else:
if not import_name in plugins_to_import:
if optional:
log.warning(_("Recommended plugin not found: %s") % import_name)
log.warning(_(u"Recommended plugin not found: %s") % import_name)
return
log.error(_("Dependency not found: %s") % import_name)
log.error(_(u"Dependency not found: %s") % import_name)
raise ImportError(_('Dependency plugin not found: [%s]') % import_name)
plugin_path, mod, plugin_info = plugins_to_import.pop(import_name)
dependencies = plugin_info.setdefault("dependencies", [])
recommendations = plugin_info.setdefault("recommendations", [])
for to_import in dependencies + recommendations:
if to_import not in self.plugins:
log.debug('Recursively import dependency of [%s]: [%s]' % (import_name, to_import))
log.debug(u'Recursively import dependency of [%s]: [%s]' % (import_name, to_import))
try:
self._import_plugins_from_dict(plugins_to_import, to_import, to_import not in dependencies)
except ImportError as e:
log.error(_("Can't import plugin %(name)s: %(error)s") % {'name':plugin_info['name'], 'error':e})
log.error(_(u"Can't import plugin %(name)s: %(error)s") % {'name':plugin_info['name'], 'error':e})
return
log.info(_("importing plugin: %s") % plugin_info['name'])
self.plugins[import_name] = getattr(mod, plugin_info['main'])(self)
@ -305,10 +305,10 @@ class SAT(service.Service):
def logPluginResults(results):
all_succeed = all([success for success, result in results])
if not all_succeed:
log.error(_("Plugins initialisation error"))
log.error(_(u"Plugins initialisation error"))
for idx, (success, result) in enumerate(results):
if not success:
log.error("error (plugin %(name)s): %(failure)s" %
log.error(u"error (plugin %(name)s): %(failure)s" %
{'name': plugin_conn_cb[idx][0], 'failure': result})
yield list_d.addCallback(logPluginResults) # FIXME: we should have a timeout here, and a way to know if a plugin freeze
@ -330,7 +330,7 @@ class SAT(service.Service):
def check_result(result):
if not result:
log.warning(_('Authentication failure of profile %s') % profile)
log.warning(_(u'Authentication failure of profile %s') % profile)
raise exceptions.PasswordError(D_("The provided profile password doesn't match."))
if not session_data: # avoid to create two profile sessions when password if specified
return self.memory.newAuthSession(password, profile)
@ -616,7 +616,7 @@ class SAT(service.Service):
profile = self.memory.getProfileName(profile_key)
assert profile
to_jid = jid.JID(raw_jid)
log.debug(_('subsciption request [%(subs_type)s] for %(jid)s') % {'subs_type': subs_type, 'jid': to_jid.full()})
log.debug(_(u'subsciption request [%(subs_type)s] for %(jid)s') % {'subs_type': subs_type, 'jid': to_jid.full()})
if subs_type == "subscribe":
self.profiles[profile].presence.subscribe(to_jid)
elif subs_type == "subscribed":
@ -721,9 +721,9 @@ class SAT(service.Service):
def confirmationAnswer(self, conf_id, accepted, data, profile):
"""Called by frontends to answer confirmation requests"""
client = self.getClient(profile)
log.debug(_("Received confirmation answer for conf_id [%(conf_id)s]: %(success)s") % {'conf_id': conf_id, 'success': _("accepted") if accepted else _("refused")})
log.debug(_(u"Received confirmation answer for conf_id [%(conf_id)s]: %(success)s") % {'conf_id': conf_id, 'success': _("accepted") if accepted else _("refused")})
if conf_id not in client._waiting_conf:
log.error(_("Received an unknown confirmation (%(id)s for %(profile)s)") % {'id': conf_id, 'profile': profile})
log.error(_(u"Received an unknown confirmation (%(id)s for %(profile)s)") % {'id': conf_id, 'profile': profile})
else:
cb = client._waiting_conf[conf_id][-1]
del client._waiting_conf[conf_id]

View file

@ -84,7 +84,7 @@ class SatXMPPClient(client.XMPPClient):
disco_d.addCallback(finish_connection)
def initializationFailed(self, reason):
log.error(_("ERROR: XMPP connection failed for profile '%(profile)s': %(reason)s" % {'profile': self.profile, 'reason': reason}))
log.error(_(u"ERROR: XMPP connection failed for profile '%(profile)s': %(reason)s" % {'profile': self.profile, 'reason': reason}))
self.conn_deferred.errback(reason.value)
try:
client.XMPPClient.initializationFailed(self, reason)
@ -251,7 +251,7 @@ class SatRosterProtocol(xmppim.RosterClientProtocol):
try:
item = self._jids.pop(entity)
except KeyError:
log.error("Received a roster remove event for an item not in cache ({})".format(entity))
log.error(u"Received a roster remove event for an item not in cache ({})".format(entity))
return
for group in item.groups:
try:
@ -260,7 +260,7 @@ class SatRosterProtocol(xmppim.RosterClientProtocol):
if not jids_set:
del self._groups[group]
except KeyError:
log.warning("there is no cache for the group [%(group)s] of the removed roster item [%(jid)s]" %
log.warning(u"there is no cache for the group [%(group)s] of the removed roster item [%(jid)s]" %
{"group": group, "jid": entity})
# then we send the bridge signal
@ -309,7 +309,7 @@ class SatPresenceProtocol(xmppim.PresenceClientProtocol):
super(SatPresenceProtocol, self).send(obj)
def availableReceived(self, entity, show=None, statuses=None, priority=0):
log.debug(_("presence update for [%(entity)s] (available, show=%(show)s statuses=%(statuses)s priority=%(priority)d)") % {'entity': entity, C.PRESENCE_SHOW: show, C.PRESENCE_STATUSES: statuses, C.PRESENCE_PRIORITY: priority})
log.debug(_(u"presence update for [%(entity)s] (available, show=%(show)s statuses=%(statuses)s priority=%(priority)d)") % {'entity': entity, C.PRESENCE_SHOW: show, C.PRESENCE_STATUSES: statuses, C.PRESENCE_PRIORITY: priority})
if not statuses:
statuses = {}
@ -328,7 +328,7 @@ class SatPresenceProtocol(xmppim.PresenceClientProtocol):
self.parent.profile)
def unavailableReceived(self, entity, statuses=None):
log.debug(_("presence update for [%(entity)s] (unavailable, statuses=%(statuses)s)") % {'entity': entity, C.PRESENCE_STATUSES: statuses})
log.debug(_(u"presence update for [%(entity)s] (unavailable, statuses=%(statuses)s)") % {'entity': entity, C.PRESENCE_STATUSES: statuses})
if not statuses:
statuses = {}
@ -384,15 +384,15 @@ class SatPresenceProtocol(xmppim.PresenceClientProtocol):
self.host.memory.delWaitingSub(entity.userhost(), self.parent.profile)
def subscribedReceived(self, entity):
log.debug(_("subscription approved for [%s]") % entity.userhost())
log.debug(_(u"subscription approved for [%s]") % entity.userhost())
self.host.bridge.subscribe('subscribed', entity.userhost(), self.parent.profile)
def unsubscribedReceived(self, entity):
log.debug(_("unsubscription confirmed for [%s]") % entity.userhost())
log.debug(_(u"unsubscription confirmed for [%s]") % entity.userhost())
self.host.bridge.subscribe('unsubscribed', entity.userhost(), self.parent.profile)
def subscribeReceived(self, entity):
log.debug(_("subscription request from [%s]") % entity.userhost())
log.debug(_(u"subscription request from [%s]") % entity.userhost())
item = self.parent.roster.getItem(entity)
if item and item.subscriptionTo:
# We automatically accept subscription if we are already subscribed to contact presence
@ -403,7 +403,7 @@ class SatPresenceProtocol(xmppim.PresenceClientProtocol):
self.host.bridge.subscribe('subscribe', entity.userhost(), self.parent.profile)
def unsubscribeReceived(self, entity):
log.debug(_("unsubscription asked for [%s]") % entity.userhost())
log.debug(_(u"unsubscription asked for [%s]") % entity.userhost())
item = self.parent.roster.getItem(entity)
if item and item.subscriptionFrom: # we automatically remove contact
log.debug(_('automatic contact deletion'))
@ -438,10 +438,10 @@ class RegisteringAuthenticator(xmlstream.ConnectAuthenticator):
self.user_email = email
self.deferred = deferred
self.profile = profile
log.debug(_("Registration asked for %(user)s@%(host)s") % {'user': user_login, 'host': jabber_host})
log.debug(_(u"Registration asked for %(user)s@%(host)s") % {'user': user_login, 'host': jabber_host})
def connectionMade(self):
log.debug(_("Connection made with %s" % self.jabber_host))
log.debug(_(u"Connection made with %s" % self.jabber_host))
self.xmlstream.namespace = "jabber:client"
self.xmlstream.sendHeader()
@ -459,11 +459,11 @@ class RegisteringAuthenticator(xmlstream.ConnectAuthenticator):
d.chainDeferred(self.deferred)
def registrationAnswer(self, answer):
log.debug(_("Registration answer: %s") % answer.toXml())
log.debug(_(u"Registration answer: %s") % answer.toXml())
self.xmlstream.sendFooter()
def registrationFailure(self, failure):
log.info(_("Registration failure: %s") % str(failure.value))
log.info(_("Registration failure: %s") % unicode(failure.value))
self.xmlstream.sendFooter()
raise failure.value

View file

@ -131,9 +131,9 @@ class Discovery(object):
# we cache items only for our own server
try:
items = self.host.memory.getEntityData(jid_, ["DISCO_ITEMS"], client.profile)["DISCO_ITEMS"]
log.debug("[%s] disco items are in cache" % jid_.full())
log.debug(u"[%s] disco items are in cache" % jid_.full())
except (KeyError, exceptions.UnknownEntityError):
log.debug("Caching [%s] disco items" % jid_.full())
log.debug(u"Caching [%s] disco items" % jid_.full())
items = yield client.disco.requestItems(jid_, nodeIdentifier)
self.host.memory.updateEntityData(jid_, "DISCO_ITEMS", items, profile_key=client.profile)
else:
@ -144,7 +144,7 @@ class Discovery(object):
def _infosEb(self, failure, entity_jid):
failure.trap(StanzaError)
log.warning(_("Error while requesting [%(jid)s]: %(error)s") % {'jid': entity_jid.full(),
log.warning(_(u"Error while requesting [%(jid)s]: %(error)s") % {'jid': entity_jid.full(),
'error': failure.getErrorMessage()})
def findServiceEntities(self, category, type_, jid_=None, profile_key=C.PROF_KEY_NONE):
@ -243,7 +243,7 @@ class Discovery(object):
s.append('<')
#TODO: manage XEP-0128 data form here
cap_hash = b64encode(sha1(''.join(s)).digest())
log.debug(_('Capability hash generated: [%s]') % cap_hash)
log.debug(_(u'Capability hash generated: [%s]') % cap_hash)
return cap_hash
@defer.inlineCallbacks

View file

@ -66,7 +66,7 @@ class Sessions(object):
session_id = str(uuid4())
elif session_id in self._sessions:
self._sessions[session_id][0].cancel()
log.warning("Session [{id}] is going to be re-initialised".format(id=session_id))
log.warning(u"Session [{id}] is going to be re-initialised".format(id=session_id))
timer = reactor.callLater(self.timeout, self._purgeSession, session_id)
if session_data is None:
session_data = {}
@ -75,7 +75,7 @@ class Sessions(object):
def _purgeSession(self, session_id):
del self._sessions[session_id]
log.debug("Session [%s] purged" % session_id)
log.debug(u"Session [%s] purged" % session_id)
def __len__(self):
return len(self._sessions)
@ -113,7 +113,7 @@ class Sessions(object):
timer.cancel()
self._purgeSession(session_id)
except KeyError:
log.debug("Session [%s] doesn't exists, timeout expired?" % session_id)
log.debug(u"Session [%s] doesn't exists, timeout expired?" % session_id)
def keys(self):
return self._sessions.keys()
@ -204,7 +204,7 @@ def fixLocalDir(silent=True):
old_default = '~/.sat'
if os.path.isfile(os.path.expanduser(old_default) + '/' + C.SAVEFILE_DATABASE):
if not silent:
log.warning(_("A database has been found in the default local_dir for previous versions (< 0.5)"))
log.warning(_(u"A database has been found in the default local_dir for previous versions (< 0.5)"))
tools_config.fixConfigOption('', 'local_dir', old_default, silent)
@ -269,10 +269,10 @@ class Memory(object):
if os.path.exists(filename):
try:
self.params.load_xml(filename)
log.debug(_("Parameters loaded from file: %s") % filename)
log.debug(_(u"Parameters loaded from file: %s") % filename)
return True
except Exception as e:
log.error(_("Can't load parameters from file: %s") % e)
log.error(_(u"Can't load parameters from file: %s") % e)
return False
def save_xml(self, filename):
@ -287,10 +287,10 @@ class Memory(object):
filename = os.path.expanduser(filename)
try:
self.params.save_xml(filename)
log.debug(_("Parameters saved to file: %s") % filename)
log.debug(_(u"Parameters saved to file: %s") % filename)
return True
except Exception as e:
log.error(_("Can't save parameters to file: %s") % e)
log.error(_(u"Can't save parameters to file: %s") % e)
return False
def load(self):
@ -323,7 +323,7 @@ class Memory(object):
def gotPersonalKey(personal_key):
"""Create the session for this profile and store the personal key"""
self.auth_sessions.newSession({C.MEMORY_CRYPTO_KEY: personal_key}, profile=profile)
log.debug('auth session created for profile %s' % profile)
log.debug(u'auth session created for profile %s' % profile)
d = PersistentDict(C.MEMORY_CRYPTO_NAMESPACE, profile).load()
d.addCallback(lambda data: BlockCipher.decrypt(key, data[C.MEMORY_CRYPTO_KEY]))
@ -337,7 +337,7 @@ class Memory(object):
try:
del self._entities_cache[profile]
except KeyError:
log.error(_("Trying to purge roster status cache for a profile not in memory: [%s]") % profile)
log.error(_(u"Trying to purge roster status cache for a profile not in memory: [%s]") % profile)
def getProfilesList(self):
return self.storage.getProfilesList()
@ -495,7 +495,7 @@ class Memory(object):
try:
presence_data = self.getEntityDatum(full_jid, "presence", profile_key)
except KeyError:
log.debug("Can't get presence data for {}".format(full_jid))
log.debug(u"Can't get presence data for {}".format(full_jid))
else:
if presence_data.show != C.PRESENCE_UNAVAILABLE:
available.append(resource)
@ -527,13 +527,13 @@ class Memory(object):
try:
presence_data = self.getEntityDatum(full_jid, "presence", profile_key)
except KeyError:
log.debug("No presence information for {}".format(full_jid))
log.debug(u"No presence information for {}".format(full_jid))
continue
priority_resources.append((resource, presence_data.priority))
try:
return max(priority_resources, key=lambda res_tuple: res_tuple[1])[0]
except ValueError:
log.warning("No resource found at all for {}".format(entity_jid))
log.warning(u"No resource found at all for {}".format(entity_jid))
return None
## Entities data ##
@ -801,7 +801,7 @@ class Memory(object):
return d.addCallback(cb)
def done(dummy):
log.debug(_('Personal data (%(ns)s, %(key)s) has been successfuly encrypted') %
log.debug(_(u'Personal data (%(ns)s, %(key)s) has been successfuly encrypted') %
{'ns': C.MEMORY_CRYPTO_NAMESPACE, 'key': data_key})
d = PersistentDict(C.MEMORY_CRYPTO_NAMESPACE, profile).load()
@ -887,6 +887,6 @@ class Memory(object):
try:
presence_data = self.getEntityDatum(entity_jid, "presence", profile_key)
except KeyError:
log.debug("No presence information for {}".format(entity_jid))
log.debug(u"No presence information for {}".format(entity_jid))
return False
return presence_data.show != C.PRESENCE_UNAVAILABLE

View file

@ -132,7 +132,7 @@ class Params(object):
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 @@ class Params(object):
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 @@ class Params(object):
@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 @@ class Params(object):
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 @@ class Params(object):
{'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 @@ class Params(object):
#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 @@ class Params(object):
"""
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 @@ class Params(object):
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 @@ class Params(object):
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 @@ class Params(object):
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":

View file

@ -114,7 +114,7 @@ class SqliteStorage(object):
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 @@ class SqliteStorage(object):
@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 @@ class SqliteStorage(object):
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 @@ class SqliteStorage(object):
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 @@ class SqliteStorage(object):
@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 @@ class SqliteStorage(object):
@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 @@ class SqliteStorage(object):
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 @@ class SqliteStorage(object):
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 @@ class SqliteStorage(object):
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 @@ class SqliteStorage(object):
@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 @@ class SqliteStorage(object):
@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 @@ class SqliteStorage(object):
@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 @@ class SqliteStorage(object):
@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 @@ class SqliteStorage(object):
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 @@ class SqliteStorage(object):
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 @@ class SqliteStorage(object):
@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 @@ class SqliteStorage(object):
@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 @@ class SqliteStorage(object):
@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 @@ class SqliteStorage(object):
@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 @@ class Updater(object):
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

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]

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