comparison src/plugins/plugin_xep_0115.py @ 1409:3265a2639182

massive (preventive) addition of 'u' (unicode) before the strings passed to logging functions
author souliane <souliane@mailoo.org>
date Thu, 16 Apr 2015 14:57:57 +0200
parents 069ad98b360d
children e0bde0d0b321
comparison
equal deleted inserted replaced
1408:8a7145138330 1409:3265a2639182
138 try: 138 try:
139 c_ver = c_elem['ver'] 139 c_ver = c_elem['ver']
140 c_hash = c_elem['hash'] 140 c_hash = c_elem['hash']
141 c_node = c_elem['node'] 141 c_node = c_elem['node']
142 except KeyError: 142 except KeyError:
143 log.warning(_('Received invalid capabilities tag: %s') % c_elem.toXml()) 143 log.warning(_(u'Received invalid capabilities tag: %s') % c_elem.toXml())
144 return 144 return
145 145
146 if c_ver in self.host.memory.disco.hashes: 146 if c_ver in self.host.memory.disco.hashes:
147 # we already know the hash, we update the jid entity 147 # we already know the hash, we update the jid entity
148 log.debug ("hash [%(hash)s] already in cache, updating entity [%(jid)s]" % {'hash': c_ver, 'jid': from_jid.full()}) 148 log.debug(u"hash [%(hash)s] already in cache, updating entity [%(jid)s]" % {'hash': c_ver, 'jid': from_jid.full()})
149 self.host.memory.updateEntityData(from_jid, C.ENTITY_CAP_HASH, c_ver, profile_key=self.profile) 149 self.host.memory.updateEntityData(from_jid, C.ENTITY_CAP_HASH, c_ver, profile_key=self.profile)
150 return 150 return
151 151
152 if c_hash != 'sha-1': # unknown hash method 152 if c_hash != 'sha-1': # unknown hash method
153 log.warning(_('Unknown hash method for entity capabilities: [%(hash_method)s] (entity: %(jid)s, node: %(node)s)') % {'hash_method':c_hash, 'jid': from_jid, 'node': c_node}) 153 log.warning(_(u'Unknown hash method for entity capabilities: [%(hash_method)s] (entity: %(jid)s, node: %(node)s)') % {'hash_method':c_hash, 'jid': from_jid, 'node': c_node})
154 154
155 def cb(dummy): 155 def cb(dummy):
156 computed_hash = self.host.memory.getEntityDatum(from_jid, C.ENTITY_CAP_HASH, self.profile) 156 computed_hash = self.host.memory.getEntityDatum(from_jid, C.ENTITY_CAP_HASH, self.profile)
157 if computed_hash != c_ver: 157 if computed_hash != c_ver:
158 log.warning(_('Computed hash differ from given hash:\ngiven: [%(given_hash)s]\ncomputed: [%(computed_hash)s]\n(entity: %(jid)s, node: %(node)s)') % {'given_hash':c_ver, 'computed_hash': computed_hash, 'jid': from_jid, 'node': c_node}) 158 log.warning(_(u'Computed hash differ from given hash:\ngiven: [%(given_hash)s]\ncomputed: [%(computed_hash)s]\n(entity: %(jid)s, node: %(node)s)') % {'given_hash':c_ver, 'computed_hash': computed_hash, 'jid': from_jid, 'node': c_node})
159 159
160 def eb(failure): 160 def eb(failure):
161 if isinstance(failure.value, error.ConnectionDone): 161 if isinstance(failure.value, error.ConnectionDone):
162 return 162 return
163 msg = failure.value.condition if hasattr(failure.value, 'condition') else failure.getErrorMessage() 163 msg = failure.value.condition if hasattr(failure.value, 'condition') else failure.getErrorMessage()
164 log.error(_("Couldn't retrieve disco info for {jid}: {error}").format(jid=from_jid.full(), error=msg)) 164 log.error(_(u"Couldn't retrieve disco info for {jid}: {error}").format(jid=from_jid.full(), error=msg))
165 165
166 d = self.host.getDiscoInfos(from_jid, self.profile) 166 d = self.host.getDiscoInfos(from_jid, self.profile)
167 d.addCallbacks(cb, eb) 167 d.addCallbacks(cb, eb)
168 # TODO: me must manage the full algorithm described at XEP-0115 #5.4 part 3 168 # TODO: me must manage the full algorithm described at XEP-0115 #5.4 part 3