detector.state = 'offline' detector = EventEmitter() DBusGMainLoop(set_as_default=True) bus = dbus.SystemBus() bus.add_match_string_non_blocking("interface='net.connman.Manager'") bus.add_message_filter(property_changed) manager = dbus.Interface(bus.get_object('net.connman', "/"), 'net.connman.Manager') def is_online(): properties = manager.GetProperties() if properties['State'] == 'online': return True return False def run(): detector.state = 'offline' if is_online: detector.emit('up') detector.state = 'online' mainloop = glib.MainLoop() mainloop.run() detector.run = run