diff frontends/src/tools/xmlui.py @ 1087:b3b7a2863060

frontends (XMLUI): use of logging system instead of print
author Goffi <goffi@goffi.org>
date Wed, 25 Jun 2014 14:01:58 +0200
parents 2cb30f46e560
children e2e1e27a3680
line wrap: on
line diff
--- a/frontends/src/tools/xmlui.py	Wed Jun 25 14:01:57 2014 +0200
+++ b/frontends/src/tools/xmlui.py	Wed Jun 25 14:01:58 2014 +0200
@@ -18,6 +18,8 @@
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
 from sat.core.i18n import _
+from sat.core.log import getLogger
+log = getLogger(__name__)
 from sat_frontends.constants import Const
 from sat.core.exceptions import DataError
 
@@ -259,7 +261,7 @@
 
                     self._parseChilds(cont, node, ('row',), data)
                 else:
-                    print(_("Unknown container [%s], using default one") % type_)
+                    log.warning(_("Unknown container [%s], using default one") % type_)
                     cont = self.widget_factory.createVerticalContainer(parent)
                     self._parseChilds(cont, node, ('widget', 'container'))
                 try:
@@ -333,7 +335,7 @@
                     ctrl = self.widget_factory.createButtonWidget(parent, value, self.onButtonPress)
                     ctrl._xmlui_param_id = (callback_id, [field.getAttribute('name') for field in node.getElementsByTagName("field_back")])
                 else:
-                    print(_("FIXME FIXME FIXME: widget type [%s] is not implemented") % type_)
+                    log.error(_("FIXME FIXME FIXME: widget type [%s] is not implemented") % type_)
                     raise NotImplementedError(_("FIXME FIXME FIXME: type [%s] is not implemented") % type_)
 
                 if self.type == 'param' and type_ not in ('text', 'button'):
@@ -342,7 +344,7 @@
                         ctrl._param_category = self._current_category
                     except (AttributeError, TypeError):  # XXX: TypeError is here because pyjamas raise a TypeError instead of an AttributeError
                         if not isinstance(ctrl, (EmptyWidget, TextWidget, LabelWidget, JidWidget)):
-                            print(_("No change listener on [%s]") % ctrl)
+                            log.warning(_("No change listener on [%s]") % ctrl)
 
                 if type_ != 'text':
                     callback = node.getAttribute("internal_callback") or None
@@ -424,7 +426,7 @@
             data['index'] = idx
         callback_id = ctrl._xmlui_callback_id
         if callback_id is None:
-            print(_("No callback_id found"))
+            log.info(_("No callback_id found"))
             return
         self._xmluiLaunchAction(callback_id, data)
 
@@ -546,12 +548,12 @@
             self._xmluiLaunchAction(self.submit_id, data)
 
         else:
-            print(_("The form data is not sent back, the type is not managed properly"))
+            log.warning(_("The form data is not sent back, the type is not managed properly"))
         self._xmluiClose()
 
     def onFormCancelled(self, ignore=None):
         """ Called when a form is cancelled """
-        print(_("Cancelling form"))
+        log.debug(_("Cancelling form"))
         self._xmluiClose()
 
     def onSaveParams(self, ignore=None):