mirror of
https://gitlab.freedesktop.org/dbus/dbus.git
synced 2026-01-21 00:10:22 +01:00
configure.ac will detect PYTHON=python3 if there is no python executable in the PATH. Bug: https://bugs.freedesktop.org/show_bug.cgi?id=101716 Reviewed-by: Philip Withnall <withnall@endlessm.com> Signed-off-by: Simon McVittie <smcv@collabora.com>
41 lines
931 B
Python
Executable file
41 lines
931 B
Python
Executable file
#!/usr/bin/env python
|
|
|
|
import os,sys
|
|
|
|
try:
|
|
import dbus
|
|
import dbus.mainloop.glib
|
|
from gi.repository import GObject
|
|
except:
|
|
print("Failed import, aborting test")
|
|
sys.exit(0)
|
|
|
|
dbus.mainloop.glib.DBusGMainLoop(set_as_default=True)
|
|
loop = GObject.MainLoop()
|
|
|
|
exitcode = 0
|
|
|
|
def handle_noreceipt():
|
|
print("Failed to get signal")
|
|
global exitcode
|
|
exitcode = 1
|
|
loop.quit()
|
|
|
|
GObject.timeout_add(7000, handle_noreceipt)
|
|
|
|
bus = dbus.SessionBus()
|
|
|
|
def sighandler(*args, **kwargs):
|
|
print("got signal")
|
|
loop.quit()
|
|
|
|
bus.add_signal_receiver(sighandler, dbus_interface='org.freedesktop.TestSuite', signal_name='Foo')
|
|
|
|
o = bus.get_object('org.freedesktop.DBus.TestSuiteEchoService', '/org/freedesktop/TestSuite')
|
|
i = dbus.Interface(o, 'org.freedesktop.TestSuite')
|
|
def nullhandler(*args, **kwargs):
|
|
pass
|
|
i.EmitFoo(reply_handler=nullhandler, error_handler=nullhandler)
|
|
|
|
loop.run()
|
|
sys.exit(exitcode)
|