massive (preventive) addition of 'u' (unicode) before the strings passed to logging functions
This commit is contained in:
parent
cc829beac7
commit
67ff77e5de
41 changed files with 272 additions and 271 deletions
|
|
@ -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]
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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":
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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:
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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})
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
|
|
|||
|
|
@ -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")
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
|
|
|||
|
|
@ -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]
|
||||
|
|
|
|||
|
|
@ -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']
|
||||
|
|
|
|||
|
|
@ -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):
|
||||
|
|
|
|||
|
|
@ -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 []
|
||||
|
|
|
|||
|
|
@ -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))
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
||||
|
||||
|
|
|
|||
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue