diff src/plugins/plugin_exp_pipe.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 697effba0310
line wrap: on
line diff
--- a/src/plugins/plugin_exp_pipe.py	Thu Apr 16 13:31:14 2015 +0200
+++ b/src/plugins/plugin_exp_pipe.py	Thu Apr 16 14:57:57 2015 +0200
@@ -68,7 +68,7 @@
             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 @@
         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 @@
             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 @@
             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 @@
                 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 @@
             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 @@
         @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 @@
             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 @@
         """
         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 @@
 
     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})