-
-
Notifications
You must be signed in to change notification settings - Fork 44
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
35 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
import os | ||
|
||
import dbus | ||
import dbus.service | ||
import dbus.mainloop.glib | ||
from gi.repository import GLib | ||
|
||
|
||
def get_pids(): | ||
# Define the path to the directory | ||
path = '/proc' | ||
|
||
# Get a list of all directories in the path | ||
directories = [d for d in os.listdir(path) if os.path.isdir(os.path.join(path, d))] | ||
|
||
# Filter out directories that contain only numbers in their names | ||
return [d for d in directories if d.isnumeric()] | ||
|
||
|
||
class HelloWorld(dbus.service.Object): | ||
def __init__(self, conn=None, object_path=None, bus_name=None): | ||
dbus.service.Object.__init__(self, conn, object_path, bus_name) | ||
|
||
@dbus.service.method(dbus_interface="com.github.stsdc.monitor.workaround.GetProcesses", in_signature="s", out_signature="as", sender_keyword="sender", connection_keyword="conn") | ||
def get_processes(self, name, sender=None, conn=None): | ||
return get_pids() | ||
|
||
if __name__ == "__main__": | ||
dbus.mainloop.glib.DBusGMainLoop(set_as_default=True) | ||
bus = dbus.SessionBus() | ||
name = dbus.service.BusName("com.github.stsdc.monitor.workaround", bus) | ||
helloworld = HelloWorld(bus, "/processes") | ||
mainloop = GLib.MainLoop() | ||
mainloop.run() | ||
|