From 3eeeb8040c763d193599381df27c8ff6b2bf27e4 Mon Sep 17 00:00:00 2001 From: Goffi Date: Sun, 10 Mar 2019 18:04:01 +0100 Subject: [PATCH] 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. --- sat/bridge/bridge_constructor/bridge_template.ini | 9 +++++++++ sat/bridge/dbus_bridge.py | 8 ++++++++ sat/bridge/pb.py | 3 +++ sat_frontends/quick_frontend/quick_app.py | 10 ++++++++++ 4 files changed, 30 insertions(+) diff --git a/sat/bridge/bridge_constructor/bridge_template.ini b/sat/bridge/bridge_constructor/bridge_template.ini index 646836d6..d2becb19 100644 --- a/sat/bridge/bridge_constructor/bridge_template.ini +++ b/sat/bridge/bridge_constructor/bridge_template.ini @@ -183,6 +183,15 @@ doc_param_0=id: id of the progression operation 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] diff --git a/sat/bridge/dbus_bridge.py b/sat/bridge/dbus_bridge.py index d39b4946..454a1e3c 100644 --- a/sat/bridge/dbus_bridge.py +++ b/sat/bridge/dbus_bridge.py @@ -128,6 +128,11 @@ class DbusObject(dbus.service.Object): # further investigations 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): @@ -681,6 +686,9 @@ class Bridge(object): 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) diff --git a/sat/bridge/pb.py b/sat/bridge/pb.py index 9c6e0288..10660afc 100644 --- a/sat/bridge/pb.py +++ b/sat/bridge/pb.py @@ -135,6 +135,9 @@ class Bridge(object): """ 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) diff --git a/sat_frontends/quick_frontend/quick_app.py b/sat_frontends/quick_frontend/quick_app.py index f863932e..85ab465f 100644 --- a/sat_frontends/quick_frontend/quick_app.py +++ b/sat_frontends/quick_frontend/quick_app.py @@ -383,6 +383,8 @@ class QuickApp(object): 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 @@ class QuickApp(object): 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