简体   繁体   中英

DBus Finch/Pidgin without X11

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

  1. dbus-launch screen
  2. finch
  3. ctrl+ac
  4. 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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM