[gnome-music/wip/jfelder/mpris-debug] mpris: Debug get pid and cmd



commit 71fa2041e2915b3b040560f1448f99d209f0004d
Author: Jean Felder <jfelder src gnome org>
Date:   Wed May 15 22:42:53 2019 +0200

    mpris: Debug get pid and cmd

 gnomemusic/mpris.py  | 20 ++++++++++++++++++++
 org.gnome.Music.json |  1 +
 2 files changed, 21 insertions(+)
---
diff --git a/gnomemusic/mpris.py b/gnomemusic/mpris.py
index 38b787b2..790ca433 100644
--- a/gnomemusic/mpris.py
+++ b/gnomemusic/mpris.py
@@ -62,6 +62,26 @@ class Server:
                        method_name,
                        parameters,
                        invocation):
+        if method_name.startswith("Get"):
+            print("request method", method_name)
+            print("parameters", parameters)
+
+            self.bus_proxy = Gio.DBusProxy.new_sync(
+                connection,
+                Gio.DBusProxyFlags.NONE,
+                None,
+                'org.freedesktop.DBus',
+                '/org/freedesktop/DBus',
+                'org.freedesktop.DBus', None)
+
+            result = self.bus_proxy.call_sync(
+                "GetConnectionUnixProcessID", GLib.Variant('(s)', (sender,)),
+                Gio.DBusCallFlags.NONE, -1, None)
+            pid = result.unpack()[0]
+            proc_path = '/proc/' + str(pid) + '/cmdline'
+            with open(proc_path, 'r') as f:
+                command_line = " ".join(f.readline().split('\0'))
+            print("pid {} and cmd: {}\n".format(pid, command_line))
 
         args = list(parameters.unpack())
         for i, sig in enumerate(self.method_inargs[method_name]):
diff --git a/org.gnome.Music.json b/org.gnome.Music.json
index 19784b23..9e574861 100644
--- a/org.gnome.Music.json
+++ b/org.gnome.Music.json
@@ -10,6 +10,7 @@
         "--share=ipc", "--socket=x11",
         "--share=network",
         "--socket=wayland",
+       "--socket=system-bus", "--socket=session-bus",
         "--talk-name=org.freedesktop.Tracker1",
         "--env=TRACKER_SPARQL_BACKEND=bus",
         "--talk-name=org.gnome.OnlineAccounts",


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]