[d-feet/6-display-statistics-and-match-rules-from-the-new-stats-interface] display statistics and match rules from the D-Bus Stats interface
- From: Will Thompson <wjt src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [d-feet/6-display-statistics-and-match-rules-from-the-new-stats-interface] display statistics and match rules from the D-Bus Stats interface
- Date: Wed, 9 May 2018 05:52:10 +0000 (UTC)
commit 5847d3905a86917587889814ff2f10ab3651b9d5
Author: Alban Crequy <alban crequy collabora co uk>
Date: Thu Aug 21 15:28:41 2014 +0100
display statistics and match rules from the D-Bus Stats interface
This requires dbus 1.9.0 for the new GetAllMatchRules call on the Stats
interface and for compiling the Stats interface by default.
The Stats interface is enabled by default on the session bus. On the system
bus, it is not enabled for non-root users by default but it can be enabled as
shown in /usr/share/doc/dbus/examples/example-system-enable-stats.conf
If the feature is not available in D-Bus, D-Feet ignores the error and
continues as before.
https://bugzilla.gnome.org/show_bug.cgi?id=735167
src/dfeet/introspection.py | 51 ++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 51 insertions(+)
---
diff --git a/src/dfeet/introspection.py b/src/dfeet/introspection.py
index a0bb75c..22f3905 100644
--- a/src/dfeet/introspection.py
+++ b/src/dfeet/introspection.py
@@ -158,6 +158,10 @@ class AddressInfo():
"""introspect the given bus name and update the tree model"""
# cleanup current tree model
self.__treemodel.clear()
+
+ # Statistics
+ self.__get_stats()
+
# start introspection
self.__dbus_node_introspect("/")
@@ -259,6 +263,53 @@ class AddressInfo():
None, GLib.VariantType.new("(s)"), Gio.DBusCallFlags.NONE, -1,
None, self.__dbus_node_introspect_cb, object_path)
+ def __get_stats_cb(self, connection, result_async, data):
+ """callback when the GetConnectionStats dbus function call finished"""
+ try:
+ res = connection.call_finish(result_async)
+ except:
+ # The stats interface might not be enabled. Ignore.
+ pass
+ else:
+ stats_iter = self.__treemodel.append(None, ["<b>Statistics</b>", None])
+ for k, v in sorted(res[0].items()):
+ self.__treemodel.append(stats_iter, [k + " = " + str(v), None])
+
+ def __get_match_rules_cb(self, connection, result_async, data):
+ """callback when the GetAllMatchRules dbus function call finished"""
+ try:
+ res = connection.call_finish(result_async)
+ except:
+ # The stats interface might not be enabled. Ignore.
+ pass
+ else:
+ if self.unique_name not in res[0]:
+ return
+
+ rules_iter = self.__treemodel.append(None, ["<b>Match rules</b>", None])
+ for v in res[0][self.unique_name]:
+ self.__treemodel.append(rules_iter, [v, None])
+
+ def __get_stats(self):
+ if self.name == 'org.freedesktop.DBus':
+ self.connection.call(
+ 'org.freedesktop.DBus', '/org/freedesktop/DBus',
+ 'org.freedesktop.DBus.Debug.Stats', 'GetStats',
+ None, GLib.VariantType.new("(a{sv})"), Gio.DBusCallFlags.NONE,
+ -1, None, self.__get_stats_cb, None)
+ elif self.name is not None:
+ self.connection.call(
+ 'org.freedesktop.DBus', '/org/freedesktop/DBus',
+ 'org.freedesktop.DBus.Debug.Stats', 'GetConnectionStats',
+ GLib.Variant('(s)', (self.name,)),
+ GLib.VariantType.new("(a{sv})"), Gio.DBusCallFlags.NONE,
+ -1, None, self.__get_stats_cb, None)
+ self.connection.call(
+ 'org.freedesktop.DBus', '/org/freedesktop/DBus',
+ 'org.freedesktop.DBus.Debug.Stats', 'GetAllMatchRules',
+ None, GLib.VariantType.new("(a{sas})"), Gio.DBusCallFlags.NONE, -1,
+ None, self.__get_match_rules_cb, None)
+
if __name__ == "__main__":
"""for debugging"""
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]