I have 2 Python programs. I just want to send a message (a long string) from the one to the other, and I want use dbus. Now, is there an easy way to do this?
For example, if the message is very small, I have partially solved the problem putting the message in the path. But then I had to use the external program dbus-send:
Server (python):
import dbus,gtk
from dbus.mainloop.glib import DBusGMainLoop
DBusGMainLoop(set_as_default=True)
bus = dbus.SessionBus()
def msg_handler(*args,**keywords):
try:
msg=str(keywords['path'][8:])
#...do smthg with msg
print msg
except:
pass
bus.add_signal_receiver(handler_function=msg_handler, dbus_interface='my.app', path_keyword='path')
gtk.main()
Client (bash:( ):
dbus-send --session /my/app/this_is_the_message my.app.App
Is there a way to write the client in Python? or also, is there a better way to achieve the same result?