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



commit 469215c523571c7de39065f9a7929000aec5a05b
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 ++++++++++++++++++++
 1 file changed, 20 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]):


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