changeset 2854:eb9fa72eb62b

core: added a "_debug" signal: this signal is a generic debugging signal which can be implemented in frontends to do specific actions, like printing data dumps.
author Goffi <goffi@goffi.org>
date Sun, 10 Mar 2019 18:04:01 +0100
parents 6901a425d882
children ef65dbce313b
files sat/bridge/bridge_constructor/bridge_template.ini sat/bridge/dbus_bridge.py sat/bridge/pb.py sat_frontends/quick_frontend/quick_app.py
diffstat 4 files changed, 30 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/sat/bridge/bridge_constructor/bridge_template.ini	Sun Mar 10 18:03:41 2019 +0100
+++ b/sat/bridge/bridge_constructor/bridge_template.ini	Sun Mar 10 18:04:01 2019 +0100
@@ -183,6 +183,15 @@
 doc_param_1=error: error message
 doc_param_2=%(doc_profile)s
 
+[_debug]
+type=signal
+category=core
+sig_in=sa{ss}s
+doc=Debug method, useful for developers
+doc_param_0=action: action to do
+doc_param_1=params: action parameters
+doc_param_2=%(doc_profile)s
+
 ;methods
 
 [getReady]
--- a/sat/bridge/dbus_bridge.py	Sun Mar 10 18:03:41 2019 +0100
+++ b/sat/bridge/dbus_bridge.py	Sun Mar 10 18:04:01 2019 +0100
@@ -129,6 +129,11 @@
         pass
 
     @dbus.service.signal(const_INT_PREFIX+const_CORE_SUFFIX,
+                         signature='sa{ss}s')
+    def _debug(self, action, params, profile):
+        pass
+
+    @dbus.service.signal(const_INT_PREFIX+const_CORE_SUFFIX,
                          signature='a{ss}sis')
     def actionNew(self, action_data, id, security_limit, profile):
         pass
@@ -681,6 +686,9 @@
         self.dbus_name = dbus.service.BusName(const_INT_PREFIX, self.session_bus)
         self.dbus_bridge = DbusObject(self.session_bus, const_OBJ_PATH)
 
+    def _debug(self, action, params, profile):
+        self.dbus_bridge._debug(action, params, profile)
+
     def actionNew(self, action_data, id, security_limit, profile):
         self.dbus_bridge.actionNew(action_data, id, security_limit, profile)
 
--- a/sat/bridge/pb.py	Sun Mar 10 18:03:41 2019 +0100
+++ b/sat/bridge/pb.py	Sun Mar 10 18:04:01 2019 +0100
@@ -135,6 +135,9 @@
         """
         self.root._bridgeReactivateSignals()
 
+    def _debug(self, action, params, profile):
+        self.sendSignal("_debug", action, params, profile)
+
     def actionNew(self, action_data, id, security_limit, profile):
         self.sendSignal("actionNew", action_data, id, security_limit, profile)
 
--- a/sat_frontends/quick_frontend/quick_app.py	Sun Mar 10 18:03:41 2019 +0100
+++ b/sat_frontends/quick_frontend/quick_app.py	Sun Mar 10 18:04:01 2019 +0100
@@ -383,6 +383,8 @@
         self.registerSignal("chatStateReceived", iface="plugin")
         self.registerSignal("messageState", iface="plugin")
         self.registerSignal("psEvent", iface="plugin")
+        # useful for debugging
+        self.registerSignal("_debug", iface="core")
 
         # FIXME: do it dynamically
         quick_games.Tarot.registerSignals(self)
@@ -1099,6 +1101,14 @@
                 answer_data=(entity, profile),
             )
 
+    def _debugHandler(self, action, parameters, profile):
+        if action == u"widgets_dump":
+            from pprint import pformat
+            log.info(u"Widgets dump:\n{data}".format(data=pformat(self.widgets._widgets)))
+        else:
+            log.warning(u"Unknown debug action: {action}".format(action=action))
+
+
     def showDialog(self, message, title, type="info", answer_cb=None, answer_data=None):
         """Show a dialog to user