DBus Finch/Pidgin without X11

半腔热情 提交于 2019-11-29 15:42:49

问题


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.


回答1:


Install screen

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



回答2:


I think finch needs some display. To launch it on the server try to use xvfb-run: http://en.wikipedia.org/wiki/Xvfb



来源:https://stackoverflow.com/questions/5530542/dbus-finch-pidgin-without-x11

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!