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.
Install screen
dbus-launch screen
finch
- ctrl+a c
python myscript
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