Mercurial > libervia-backend
comparison src/plugins/plugin_xep_0096.py @ 1583:d46aae87c03a
plugins XEP-0047, XEP-0065, XEP-0096: fixed use of failure.condition insteand of failure.value + removed gettext use for local logs
author | Goffi <goffi@goffi.org> |
---|---|
date | Fri, 13 Nov 2015 16:46:31 +0100 |
parents | d04d7402b8e9 |
children | 846a39900fa6 |
comparison
equal
deleted
inserted
replaced
1582:a41cc0849008 | 1583:d46aae87c03a |
---|---|
156 if stream_method == self.host.plugins["XEP-0065"].NAMESPACE: | 156 if stream_method == self.host.plugins["XEP-0065"].NAMESPACE: |
157 plugin = self.host.plugins["XEP-0065"] | 157 plugin = self.host.plugins["XEP-0065"] |
158 elif stream_method == self.host.plugins["XEP-0047"].NAMESPACE: | 158 elif stream_method == self.host.plugins["XEP-0047"].NAMESPACE: |
159 plugin = self.host.plugins["XEP-0047"] | 159 plugin = self.host.plugins["XEP-0047"] |
160 else: | 160 else: |
161 log.error(_("Unknown stream method, this should not happen at this stage, cancelling transfer")) | 161 log.error(u"Unknown stream method, this should not happen at this stage, cancelling transfer") |
162 else: | 162 else: |
163 log.warning(_("Can't find a valid stream method")) | 163 log.warning(u"Can't find a valid stream method") |
164 self._si.sendError(iq_elt, 'not-acceptable', profile) | 164 self._si.sendError(iq_elt, 'not-acceptable', profile) |
165 return | 165 return |
166 | 166 |
167 #if we are here, the transfer can start, we just need user's agreement | 167 #if we are here, the transfer can start, we just need user's agreement |
168 data = {"name": filename, "peer_jid": peer_jid, "size": file_size, "date": file_date, "hash": file_hash, "desc": file_desc, | 168 data = {"name": filename, "peer_jid": peer_jid, "size": file_size, "date": file_date, "hash": file_hash, "desc": file_desc, |
243 | 243 |
244 @param id: stream id | 244 @param id: stream id |
245 @param data: session data | 245 @param data: session data |
246 @param profile: %(doc_profile)s | 246 @param profile: %(doc_profile)s |
247 """ | 247 """ |
248 log.warning(u'Transfer {si_id} failed: {reason}'.format(reason=unicode(failure.condition), **data)) | 248 log.warning(u'Transfer {si_id} failed: {reason}'.format(reason=unicode(failure.value), **data)) |
249 data['file_obj'].close() | 249 data['file_obj'].close() |
250 | 250 |
251 def _sendFile(self, peer_jid_s, filepath, name, desc, profile=C.PROF_KEY_NONE): | 251 def _sendFile(self, peer_jid_s, filepath, name, desc, profile=C.PROF_KEY_NONE): |
252 return self.sendFile(jid.JID(peer_jid_s), filepath, name or None, desc or None, profile) | 252 return self.sendFile(jid.JID(peer_jid_s), filepath, name or None, desc or None, profile) |
253 | 253 |
331 from_s = stanza_err.stanza['from'] | 331 from_s = stanza_err.stanza['from'] |
332 log.info(u"File transfer refused by {}".format(from_s)) | 332 log.info(u"File transfer refused by {}".format(from_s)) |
333 self.host.bridge.newAlert(_("The contact {} has refused your file").format(from_s), _("File refused"), "INFO", client.profile) | 333 self.host.bridge.newAlert(_("The contact {} has refused your file").format(from_s), _("File refused"), "INFO", client.profile) |
334 else: | 334 else: |
335 log.warning(_(u"Error during file transfer")) | 335 log.warning(_(u"Error during file transfer")) |
336 self.host.bridge.newAlert(_(u"Something went wrong during the file transfer session intialisation: {reason}").format(reason=unicode(stanza_err.condition)), _("File transfer error"), "ERROR", client.profile) | 336 self.host.bridge.newAlert(_(u"Something went wrong during the file transfer session intialisation: {reason}").format(reason=unicode(stanza_err.value)), _("File transfer error"), "ERROR", client.profile) |
337 elif failure.check(exceptions.DataError): | 337 elif failure.check(exceptions.DataError): |
338 log.warning(u'Invalid stanza received') | 338 log.warning(u'Invalid stanza received') |
339 else: | 339 else: |
340 log.error(u'Error while proposing stream: {}'.format(failure)) | 340 log.error(u'Error while proposing stream: {}'.format(failure)) |
341 | 341 |
347 | 347 |
348 def _sendEb(self, failure, sid, file_obj, profile): | 348 def _sendEb(self, failure, sid, file_obj, profile): |
349 log.warning(_(u'transfer {sid} failed [{profile}]: {reason}').format( | 349 log.warning(_(u'transfer {sid} failed [{profile}]: {reason}').format( |
350 sid=sid, | 350 sid=sid, |
351 profile=profile, | 351 profile=profile, |
352 reason=unicode(failure.condition), | 352 reason=unicode(failure.value), |
353 )) | 353 )) |
354 file_obj.close() | 354 file_obj.close() |