python - DBus Finch/Pidgin 不带 X11

标签 python x11 dbus finch pidgin

我想在我的服务器上编写一些 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,并且运行脚本也会给出相同的错误。

解决方案?谢谢。

最佳答案

安装屏幕

  1. dbus 启动屏幕
  2. 雀科
  3. ctrl+ac
  4. python myscript

关于python - DBus Finch/Pidgin 不带 X11,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5530542/

相关文章:

python - flask jinja2.exceptions.TemplateSyntaxError

python - 如何在python中显示特定dbus总线名称(/org/bluez)的接口(interface)?

linux - dbus:dbus_bus_get_unique_name 有问题

python - 如何在 Pandas 中获取多个值

javascript - 在 python json 加载中解析日期时间

负值的 Python sort() 问题

c++ - OpenGL - 在 ubuntu 中的线程上创建 vbo?

c - 使用根 X11 窗口作为 SDL2 主窗口

haskell - 使用 xmonad 使每个窗口透明

google-chrome - 来自 Chrome 扩展程序的 X11/DBUS 消息传递?