summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Bechtold <thomasbechtold@jpberlin.de>2018-05-27 06:39:56 +0000
committerThomas Bechtold <thomasbechtold@jpberlin.de>2018-05-27 06:39:56 +0000
commit4114a65a135cc7e1ee2e5998561c30336ff320f3 (patch)
tree0ffa6ec69a3e92baa3dfc71699b48f965e8f859f
parent107e51b858c9da439656a378df457b814c7af1ac (diff)
parent5847d3905a86917587889814ff2f10ab3651b9d5 (diff)
downloadd-feet-4114a65a135cc7e1ee2e5998561c30336ff320f3.tar.gz
Merge branch '6-display-statistics-and-match-rules-from-the-new-stats-interface' into 'master'
Display statistics and match rules from the Stats interface Closes #6 See merge request GNOME/d-feet!3
-rw-r--r--src/dfeet/introspection.py51
1 files changed, 51 insertions, 0 deletions
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"""