0

My system is a centos with no gui. I have a server application which "listens" for a method call in a session dbus. It apparently works fine. I have pydbus and python3-gobject installed fine, I also have dbus-launch working. This is the server application:

from pydbus import SessionBus
from gi.repository import GLib
import time

# Variables / Constants / Instantiation...
bus = SessionBus()
BUS = "org.mybus.demo.test"
loop = GLib.MainLoop()
message_count = 0

class DBusService_XML():
    """
    DBus Service XML Definition.
    type = "i" for integer, "s" for string, "d" for double, "as" list of string data.
    """
    dbus = """
    <node>
        <interface name="{}">
            <method name='greeting'>
                <arg type="s" name="input" direction="in">
                </arg>
                <arg type="s" name="output" direction="out">
                </arg>
            </method>
        </interface>
    </node>
    """.format(BUS)

    def greeting(self, clientName):
        "Receive and send arg"
        print("{} is asking for name".format(clientName))
        return "Hello {}, Im Kyle".format(clientName)

if __name__ == "__main__":
    bus.publish(BUS, DBusService_XML())
    loop.run()

Now in order to call that server method, from another terminal (same user) I tried to use my client application, which failed, then I tried gdbus application which failed with the same error as below:

# dbus-launch gdbus call --session --dest org.mybus.demo.test --object-path /org/mybus/demo/test --method org.mybus.demo.test.greeting "Julia"
Error: GDBus.Error:org.freedesktop.DBus.Error.ServiceUnknown: The name org.mybus.demo.test was not provided by any .service files

From another machine with Desktop Environment everything works fine. I searched around but couldn't find a way to use dbus in that situation. Can anyone help?

Adriano_Pinaffo
  • 1,429
  • 4
  • 23
  • 46

1 Answers1

0

Unless your service is already running when you call that method from the client, you will need to enable service activation for it, which involves writing a org.mybus.demo.test.service file and putting it in /usr/share/dbus-1/services. See the specification. It would probably look something like:

[D-BUS Service]
Name=org.mybus.demo.test
Exec=/path/to/your/application.py
Philip Withnall
  • 5,293
  • 14
  • 28