我的系统是没有gui的centos。我有一个服务器应用程序,它“监听”会话中的方法调用dbus
。它显然工作正常。我已经安装好了pydbus
,python3-gobject
我也有dbus-launch
工作。这是服务器应用程序:
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()
现在为了调用该服务器方法,从另一个终端(同一个用户)我尝试使用我的客户端应用程序,但失败了,然后我尝试gdbus
了失败的应用程序,错误如下:
# 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
从另一台具有桌面环境的机器上一切正常。我四处搜寻,但找不到在那种情况下使用 dbus 的方法。任何人都可以帮忙吗?