blob: e1010a54263392cab7089c816044a412bac86fd7 [file] [log] [blame]
Brad Bishop9bba3412015-09-21 22:01:13 -04001#!/usr/bin/env python
2
3# Contributors Listed Below - COPYRIGHT 2015
4# [+] International Business Machines Corp.
5#
6#
7# Licensed under the Apache License, Version 2.0 (the "License");
8# you may not use this file except in compliance with the License.
9# You may obtain a copy of the License at
10#
11# http://www.apache.org/licenses/LICENSE-2.0
12#
13# Unless required by applicable law or agreed to in writing, software
14# distributed under the License is distributed on an "AS IS" BASIS,
15# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
16# implied. See the License for the specific language governing
17# permissions and limitations under the License.
18
19import dbus
20import dbus.service
21import dbus.mainloop.glib
22import gobject
23
24SERVICE_PREFIX = 'org.openbmc.examples'
25IFACE_PREFIX = 'org.openbmc.examples'
26BASE_OBJ_PATH = '/org/openbmc/examples/'
27
28def signal_callback(*a, **kw):
29 print "Got signal:"
30 print "intf: " + kw.get('intf', 'none')
31 print "path: " + kw.get('path', 'none')
32 print "member: " + kw.get('member', 'none')
33
34if __name__ == '__main__':
35 dbus.mainloop.glib.DBusGMainLoop(set_as_default=True)
36
37 bus = dbus.SystemBus()
38
39 obj0 = bus.get_object(SERVICE_PREFIX + '.PythonService0',
40 BASE_OBJ_PATH + 'path0/PythonObj')
41 obj1 = bus.get_object(SERVICE_PREFIX + '.PythonService1',
42 BASE_OBJ_PATH + 'path1/PythonObj')
43 echo0= dbus.Interface(obj0,
44 dbus_interface=IFACE_PREFIX + '.Echo')
45 echo1= dbus.Interface(obj0,
46 dbus_interface=IFACE_PREFIX + '.Echo')
47
48 print "Invoking Echo methods...."
49 print(echo0.Echo("hello"))
50 print(echo1.Echo("there"))
51
52 bus.add_signal_receiver(signal_callback, interface_keyword = 'intf',
53 path_keyword = 'path',
54 member_keyword = 'member')
55
56 print "Waiting for signals... (call a sample method to see something here)"
57 print "Press Ctrl^C to quit"
58 mainloop = gobject.MainLoop()
59
60 mainloop.run()