我的系统是一个没有图形用户界面的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的方法。有人能帮忙吗?