本文介绍了没有X11的DBus Finch/Pidgin的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在服务器上做一些Python脚本,在其中可以通过DBus Python库与finch(控制台的界面为pidgin,界面与links2相似)进行通信,以发送消息或检查好友在线状态.

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.

如果在X中执行此操作,则有效.在X终端中运行finch并在另一个终端中运行Python脚本,而不会出现错误/异常.

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.

但是,如果您不使用X 进行操作,则必须在TTY1(ctrl + alt + f1)中运行finch,在TTY2(ctrl + alt + f2)中运行python脚本,但是python脚本将失败.

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.

以下是脚本的前几行:

import dbus
bus = dbus.SessionBus() # gives EXCEPTION error
obj = bus.get_object("im.pidgin.purple.PurpleService", "/im/pidgin/purple/PurpleObject")
...

EXCEPTION错误为:

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.`

我读过某个地方,也许您需要在同一TTY中运行finch和脚本.但是我无法正确测试它,因为它不像在一行上运行cd而在下一行上运行ls.您键入finch,它会运行,并且您不能再键入任何其他命令,例如links2.我尝试运行finch &,但是似乎暂停了finch,并且运行脚本也给出了相同的错误.

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.

解决方案?谢谢.

推荐答案

安装screen

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

这篇关于没有X11的DBus Finch/Pidgin的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-22 21:02