diff frontends/src/wix/main_window.py @ 1011:5a6354ff468c

wix: use of new logging system
author Goffi <goffi@goffi.org>
date Mon, 05 May 2014 20:12:21 +0200
parents 3a96920c07b7
children c4c14480715a
line wrap: on
line diff
--- a/frontends/src/wix/main_window.py	Mon May 05 20:12:19 2014 +0200
+++ b/frontends/src/wix/main_window.py	Mon May 05 20:12:21 2014 +0200
@@ -29,7 +29,8 @@
 from sat_frontends.wix.profile_manager import ProfileManager
 import os.path
 from sat.tools.jid  import JID
-from logging import debug, info, warning, error
+from sat.core.log import getLogger
+log = getLogger(__name__)
 from sat_frontends.wix.constants import Const
 
 idCONNECT,\
@@ -104,7 +105,7 @@
 
     def plug_profile(self, profile_key='@DEFAULT@'):
         """Hide profile panel then plug profile"""
-        debug (_('plugin profile %s' % profile_key))
+        log.debug (_('plugin profile %s' % profile_key))
         self.profile_pan.Hide()
         self.contact_list.Show()
         self.sizer.Layout()
@@ -113,7 +114,7 @@
         super(MainWindow, self).plug_profile(profile_key)
 
     def createMenus(self):
-        info(_("Creating menus"))
+        log.info(_("Creating menus"))
         connectMenu = wx.Menu()
         connectMenu.Append(idCONNECT, _("&Connect	CTRL-c"),_(" Connect to the server"))
         connectMenu.Append(idDISCONNECT, _("&Disconnect	CTRL-d"),_(" Disconnect from the server"))
@@ -195,7 +196,7 @@
             flags = wx.YES_NO | wx.ICON_QUESTION
         else:
             flags = wx.OK | wx.ICON_INFORMATION
-            error(_('unmanaged dialog type: %s'), type)
+            log.error(_('unmanaged dialog type: %s'), type)
         dlg = wx.MessageDialog(self, message, title, flags)
         answer = dlg.ShowModal()
         dlg.Destroy()
@@ -236,7 +237,7 @@
                 # action was a one shot, nothing to do
                 pass
             elif "xmlui" in data:
-                debug (_("XML user interface received"))
+                log.debug (_("XML user interface received"))
                 XMLUI(self, xml_data = data['xmlui'])
             else:
                 dlg = wx.MessageDialog(self, _(u"Unmanaged action result"),
@@ -259,10 +260,10 @@
         #TODO: refactor this in QuickApp
         if not self.check_profile(profile):
             return
-        debug (_("Confirmation asked"))
+        log.debug (_("Confirmation asked"))
         answer_data={}
         if confirmation_type == "FILE_TRANSFER":
-            debug (_("File transfer confirmation asked"))
+            log.debug (_("File transfer confirmation asked"))
             dlg = wx.MessageDialog(self, _("The contact %(jid)s wants to send you the file %(filename)s\nDo you accept ?") % {'jid':data["from"], 'filename':data["filename"]},
                                    _('File Request'),
                                    wx.YES_NO | wx.ICON_QUESTION
@@ -282,7 +283,7 @@
             dlg.Destroy()
 
         elif confirmation_type == "YES/NO":
-            debug (_("Yes/No confirmation asked"))
+            log.debug (_("Yes/No confirmation asked"))
             dlg = wx.MessageDialog(self, data["message"],
                                    _('Confirmation'),
                                    wx.YES_NO | wx.ICON_QUESTION
@@ -298,9 +299,9 @@
     def actionResult(self, type, id, data, profile):
         if not self.check_profile(profile):
             return
-        debug (_("actionResult: type = [%(type)s] id = [%(id)s] data = [%(data)s]") % {'type':type, 'id':id, 'data':data})
+        log.debug (_("actionResult: type = [%(type)s] id = [%(id)s] data = [%(data)s]") % {'type':type, 'id':id, 'data':data})
         if not id in self.current_action_ids:
-            debug (_('unknown id, ignoring'))
+            log.debug (_('unknown id, ignoring'))
             return
         if type == "SUPPRESS":
             self.current_action_ids.remove(id)
@@ -322,7 +323,7 @@
             dlg.Destroy()
         elif type == "XMLUI":
             self.current_action_ids.remove(id)
-            debug (_("XML user interface received"))
+            log.debug (_("XML user interface received"))
             misc = {}
             #FIXME FIXME FIXME: must clean all this crap !
             title = _('Form')
@@ -344,7 +345,7 @@
                 del self.current_action_ids_cb[id]
                 callback(data)
         else:
-            error (_("FIXME FIXME FIXME: type [%s] not implemented") % type)
+            log.error (_("FIXME FIXME FIXME: type [%s] not implemented") % type)
             raise NotImplementedError
 
 
@@ -374,7 +375,7 @@
     ### events ###
 
     def onContactActivated(self, jid):
-        debug (_("onContactActivated: %s"), jid)
+        log.debug (_("onContactActivated: %s"), jid)
         if self.chat_wins[jid.bare].IsShown():
             self.chat_wins[jid.bare].Hide()
         else:
@@ -392,11 +393,11 @@
         self.bridge.setPresence(show=show, statuses={'default': status}, profile_key=self.profile)  #FIXME: manage multilingual statuses
 
     def onStatusChange(self, e):
-        debug(_("Status change request"))
+        log.debug(_("Status change request"))
         self.__updateStatus()
 
     def onParam(self, e):
-        debug(_("Param request"))
+        log.debug(_("Param request"))
         def success(params):
             XMLUI(self, xml_data=params, title=_("Configuration"))
 
@@ -430,7 +431,7 @@
         self.Close()
 
     def onShowProfile(self, e):
-        debug(_("Show contact's profile request"))
+        log.debug(_("Show contact's profile request"))
         target = self.contact_list.getSelection()
         if not target:
             dlg = wx.MessageDialog(self, _("You haven't selected any contact !"),
@@ -446,11 +447,11 @@
 
     def onProfileReceived(self, data):
         """Called when a profile is received"""
-        debug (_('Profile received: [%s]') % data)
+        log.debug (_('Profile received: [%s]') % data)
         Profile(self, data)
 
     def onJoinRoom(self, e):
-        warning('FIXME: temporary menu, must be improved')
+        log.warning('FIXME: temporary menu, must be improved')
         #TODO: a proper MUC room joining dialog with nickname etc
         dlg = wx.TextEntryDialog(
                 self, _("Please enter MUC's JID"),
@@ -461,18 +462,18 @@
             if room_jid.is_valid():
                 self.bridge.joinMUC(room_jid, self.profiles[self.profile]['whoami'].node, {}, self.profile)
             else:
-                error (_("'%s' is an invalid JID !"), room_jid)
+                log.error (_("'%s' is an invalid JID !"), room_jid)
 
     def onClose(self, e):
         QuickApp.onExit(self)
-        info(_("Exiting..."))
+        log.info(_("Exiting..."))
         for win in self.chat_wins:
             self.chat_wins[win].Destroy()
         self.tray_icon.Destroy()
         e.Skip()
 
     def onTrayClick(self, e):
-        debug(_("Tray Click"))
+        log.debug(_("Tray Click"))
         if self.IsShown():
             self.Hide()
         else: