1#!/usr/bin/env python 2 3import os,sys 4 5try: 6 import gobject 7 import dbus 8 import dbus.mainloop.glib 9except: 10 print "Failed import, aborting test" 11 sys.exit(0) 12 13dbus.mainloop.glib.DBusGMainLoop(set_as_default=True) 14loop = gobject.MainLoop() 15 16exitcode = 0 17 18def handle_noreceipt(): 19 print "Failed to get signal" 20 global exitcode 21 exitcode = 1 22 loop.quit() 23 24gobject.timeout_add(7000, handle_noreceipt) 25 26bus = dbus.SessionBus() 27 28def sighandler(*args, **kwargs): 29 print "got signal" 30 loop.quit() 31 32bus.add_signal_receiver(sighandler, dbus_interface='org.freedesktop.TestSuite', signal_name='Foo') 33 34o = bus.get_object('org.freedesktop.DBus.TestSuiteEchoService', '/org/freedesktop/TestSuite') 35i = dbus.Interface(o, 'org.freedesktop.TestSuite') 36def nullhandler(*args, **kwargs): 37 pass 38i.EmitFoo(reply_handler=nullhandler, error_handler=nullhandler) 39 40loop.run() 41sys.exit(exitcode) 42