Update start-notification-service.py
Run CI Tests / test (push) Failing after 51s

This commit is contained in:
2025-08-16 12:05:03 +02:00
parent c74aa024d3
commit 29ccb26bad
+53 -22
View File
@@ -1,37 +1,68 @@
#!/usr/bin/env python3
import sys
from gi.repository import GLib, Gio
from pydbus import SessionBus
from gi.repository import GLib
# XML de linterface Notifications (simplifié pour tests)
NOTIF_IFACE_XML = """
# Interface XML (simplifiée pour Notifications)
NOTIF_IFACE_XML = """
<node>
<interface name="org.freedesktop.Notifications">
<method name="Notify">
<arg type="s" name="app_name" direction="in"/>
<arg type="u" name="replaces_id" direction="in"/>
<arg type="s" name="app_icon" direction="in"/>
<arg type="s" name="summary" direction="in"/>
<arg type="s" name="body" direction="in"/>
<arg type="as" name="actions" direction="in"/>
<arg type="a{sv}" name="hints" direction="in"/>
<arg type="i" name="expire_timeout" direction="in"/>
<arg type="u" name="id" direction="out"/>
</method>
<method name="CloseNotification">
<arg type="u" name="id" direction="in"/>
</method>
<method name="GetServerInformation">
<arg type="s" name="name" direction="out"/>
<arg type="s" name="vendor" direction="out"/>
<arg type="s" name="version" direction="out"/>
<arg type="s" name="spec_version" direction="out"/>
</method>
<method name="GetCapabilities">
<arg type="as" name="caps" direction="out"/>
</method>
<signal name="NotificationClosed">
<arg type="u" name="id"/>
<arg type="u" name="reason"/>
</signal>
<signal name="ActionInvoked">
<arg type="u" name="id"/>
<arg type="s" name="action_key"/>
</signal>
</interface>
</node>
"""
class NotificationService:
"""
<node>
<interface name="org.freedesktop.Notifications">
<method name="Notify">
<arg type="s" name="app_name" direction="in"/>
<arg type="u" name="id" direction="out"/>
</method>
</interface>
</node>
"""
def Notify(self, app_name):
print(f"[INFO] Notification received from {app_name}")
return 1 # ID fictif
def Notify(self, *args, **kwargs):
print("[INFO] Notify called with:", args)
return 1 # fake notification id
if __name__ == "__main__":
print("[INFO] Starting Notification service…")
bus = SessionBus()
bus.publish("org.freedesktop.Notifications", NotificationService())
print("[INFO] Service registered on DBus, waiting for calls.")
GLib.MainLoop().run()
def CloseNotification(self, id):
print(f"[INFO] CloseNotification {id}")
def GetServerInformation(self):
return ("FakeServer", "FakeVendor", "1.0", "1.2")
def GetCapabilities(self):
return ["body", "actions"]
print("[INFO] Starting fake org.freedesktop.Notifications service...")
bus = SessionBus()
node_info = Gio.DBusNodeInfo.new_for_xml(NOTIF_IFACE_XML)
bus.register_object("/org/freedesktop/Notifications",
NotificationService(),
node_info.interfaces[0])
print("[INFO] Service registered. Waiting for calls...")
GLib.MainLoop().run()