root/software/dbus_test/client.py @ 397a8855
| cd10f9a6 | David Sorber | #!/usr/bin/env python3
|
||
import dbus
|
||||
| 7eba70e1 | David Sorber | def error_func():
|
||
print('I got called ERROR')
|
||||
def reply_func():
|
||||
print('I got called REPLY')
|
||||
| cd10f9a6 | David Sorber | class Client():
|
||
| f94cb2af | David Sorber | def __init__(self):
|
||
bus = dbus.SystemBus()
|
||||
service = bus.get_object('com.example.service', "/com/example/service")
|
||||
self._message = service.get_dbus_method('get_message', 'com.example.service.Message')
|
||||
| 7eba70e1 | David Sorber | self._poke = service.get_dbus_method('poke', 'com.example.service.Poke')
|
||
| f94cb2af | David Sorber | self._quit = service.get_dbus_method('quit', 'com.example.service.Quit')
|
||
| cd10f9a6 | David Sorber | |||
| f94cb2af | David Sorber | def run(self):
|
||
print("Mesage from service:", self._message())
|
||||
| 7eba70e1 | David Sorber | self._poke() #reply_handler=reply_func, error_handler=error_func)
|
||
print('post poke')
|
||||
self._poke() #reply_handler=reply_func, error_handler=error_func)
|
||||
print('post poke')
|
||||
self._poke() #reply_handler=reply_func, error_handler=error_func)
|
||||
print('post poke')
|
||||
# ~ self._quit()
|
||||
| cd10f9a6 | David Sorber | |||
if __name__ == "__main__":
|
||||
| f94cb2af | David Sorber | Client().run()
|