DBus Finch/Pidgin 不带 X11

发布于 2024-10-29 22:42:07 字数 1062 浏览 4 评论 0原文

我想在我的服务器上编写一些 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

待天淡蓝洁白时 2024-11-05 22:42:07

安装screen

  1. dbus-launch screen
  2. finch
  3. ctrl+ac
  4. python myscript

Install screen

  1. dbus-launch screen
  2. finch
  3. ctrl+a c
  4. python myscript
夏有森光若流苏 2024-11-05 22:42:07

我认为芬奇需要一些展示。要在服务器上启动它,请尝试使用xvfb-runhttp://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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文