Hi!
I'm trying to write small application which allows to send dbus commands (to Amarok) through web page.
I'm using python + mod_wsgi, because I need to run the script with the same user as Amarok.
When I connect to the Amarok through normal shell, it works. But after connecting through the script, I get the following error:
DBusException: org.freedesktop.DBus.Error.Spawn.ExecFailed: /usr/bin/dbus-launch terminated abnormally with the following error: Autolaunch error: X11 initialization failed.
The code which is connecting to the Amarok:
import dbus
conn = dbus.SessionBus().get_object('org.kde.amarok','/Player')
Do you know what should I do to connect through dbus to Amarok?
Thanks a lot for help!
Update:
I'll give you some additional information about configuration:
httpd.conf:
LoadModule wsgi_module modules/mod_wsgi.so
WSGIScriptAlias /amarok /var/www/amarok-python/config.wsgi
WSGIDaemonProcess l user=wojtas group=wojtas processes=1
WSGIProcessGroup l
config.WSGI:
import sys
path='/var/www/amarok-python'
if path not in sys.path:
sys.path.append(path)
import index
application=index.application
Code of the application (index.py):
import dbus
from os import getuid
def connect():
conn = dbus.SessionBus().get_object('org.kde.amarok','/Player')
conn.Start()
return conn
def application(environ,start_response):
status= '200 OK'
connection=connect()
output=str(getuid())
response_headers= [('Content-type','text/html'), ('Content-Length', str(len(output)))]
start_response (status,response_headers)
return [output]