python-validity/scripts/lsdbus.py
Arvid Norlander 9dc0c14aed
Automated formatting with YAPF.
PEP8 settings are used except the low 80 column limit has be increased
to a more reasonable 100 columns.
2020-08-06 11:46:19 +02:00

25 lines
593 B
Python
Executable file

#!/usr/bin/env python3
import argparse
import re
import dbus
import dbus.mainloop.glib
dbus.mainloop.glib.DBusGMainLoop(set_as_default=True)
from gi.repository import GObject, GLib
import pwd
bus = dbus.SystemBus()
o = bus.get_object('org.freedesktop.DBus', '/org/freedesktop/DBus')
o = dbus.Interface(o, 'org.freedesktop.DBus')
ls = o.ListNames()
for n in ls:
if n[0] != ':':
continue
pid = o.GetConnectionUnixProcessID(n)
with open('/proc/%d/cmdline' % pid) as f:
s = f.read()
s = s.split('\0')
print('%-10s %-5d %s' % (n, pid, ' '.join(s)))