3 # Copyright (C) 2012 Intel Corporation
5 # This program is free software; you can redistribute it and/or
6 # modify it under the terms of the GNU General Public License
7 # as published by the Free Software Foundation; either version 2
8 # of the License, or (at your option) any later version.
10 # This program is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 # GNU General Public License for more details.
16 # ChengTao.Liu <chengtaox.liu@intel.com>
17 # Yuanyuan,Zou <yuanyuanx.zou@intel.com>
18 """ testkit dbus service"""
23 from dbus.mainloop.glib import DBusGMainLoop
27 class DeviceKeeper(dbus.service.Object):
29 testkit dbus service implementation
35 @dbus.service.method(dbus_interface="com.intel.testkit", in_signature="s", out_signature="b")
36 def addDevice(self, device_id):
37 if device_id in self._devices:
40 self._devices.append(device_id)
43 @dbus.service.method(dbus_interface="com.intel.testkit", in_signature="s", out_signature="")
44 def removeDevice(self, device_id):
45 if device_id in self._devices:
46 self._devices.remove(device_id)
50 if __name__ == '__main__':
51 DBusGMainLoop(set_as_default=True)
52 gobject.threads_init()
53 bus = dbus.SessionBus()
54 if bus.name_has_owner('com.intel.testkit'):
55 print 'An instance of testkit service is running!'
57 bus_name = dbus.service.BusName('com.intel.testkit', bus)
58 t_object = DeviceKeeper(bus_name, "/com/intel/testkit/devices")
60 loop = gobject.MainLoop()