DBus Finch/Pidgin 不带 X11
我想在我的服务器上编写一些 Python 脚本,以便与 finch
通信(pidgin
的控制台界面,界面看起来像 links2
)通过DBus Python库发送消息或检查好友在线状态。
如果您在 X 中执行此操作,则此操作有效。在 X 终端中运行 finch
并在另一个终端中运行 Python 脚本,不会出现错误/异常。
但是,如果您没有 X,则必须在 TTY1 中运行 finch
(ctrl+alt+f1),并在 TTY2 中运行 python 脚本 (ctrl+alt+f2),但是python 脚本将失败。
以下是脚本的前几行:
import dbus
bus = dbus.SessionBus() # gives EXCEPTION error
obj = bus.get_object("im.pidgin.purple.PurpleService", "/im/pidgin/purple/PurpleObject")
...
异常错误是:
dbus.exceptions.DBusException: org.freedesktop.DBus.Error.Spawn.ExecFailed: dbus-launch failed to autolaunch D-Bus session: Autolaunch error: X11 initialization failed.`
我在某处读到,也许您需要在同一个 TTY 中运行 finch
和脚本。但是我无法正确测试它,因为它不像在一行上运行 cd 并在下一行上运行 ls 。您输入 finch
,它就会运行,并且您无法再输入任何其他命令,例如 links2
。我尝试运行 finch &
但似乎暂停了 finch
,并且运行脚本也会给出相同的错误。
解决方案?谢谢。
I want to do some Python scripting on my server where I can communicate with finch
(A console interface of pidgin
, with the interface looking like links2
) through the DBus Python library to send messages or check for buddy online status.
This works if you do it in X. Run finch
in an X terminal and run the Python script in another terminal with no errors/exceptions.
But if you do it without X, you have to run finch
in TTY1 (ctrl+alt+f1) and the python script in TTY2 (ctrl+alt+f2) but the python script will fail.
The following is the first few lines of the script:
import dbus
bus = dbus.SessionBus() # gives EXCEPTION error
obj = bus.get_object("im.pidgin.purple.PurpleService", "/im/pidgin/purple/PurpleObject")
...
The EXCEPTION error is:
dbus.exceptions.DBusException: org.freedesktop.DBus.Error.Spawn.ExecFailed: dbus-launch failed to autolaunch D-Bus session: Autolaunch error: X11 initialization failed.`
I read somewhere that maybe you need to run finch
and the script both in the same TTY. However I am unable to test that properly because it is not like running cd
on one line and ls
on the next line. You type finch
, it runs, and you can't type any other commands anymore, like links2
. I tried running finch &
instead but that seems to pause finch
, and running the script also gives the same error.
Solution? Thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
安装
screen
dbus-launch screen
finch
python myscript
Install
screen
dbus-launch screen
finch
python myscript
我认为芬奇需要一些展示。要在服务器上启动它,请尝试使用xvfb-run:http://en .wikipedia.org/wiki/Xvfb
I think finch needs some display. To launch it on the server try to use xvfb-run: http://en.wikipedia.org/wiki/Xvfb