2
我正在尝试编写允许通过网页发送dbus命令(至Amarok)的小型应用程序。
我正在使用python + mod_wsgi,因为我需要使用与Amarok相同的用户来运行脚本。
当我通过普通shell连接到Amarok时,它可以工作。但是,通过脚本连接后,我收到以下错误:通过Python中的mod_wsgi进行Dbus连接
DBusException: org.freedesktop.DBus.Error.Spawn.ExecFailed: /usr/bin/dbus-launch terminated abnormally with the following error: Autolaunch error: X11 initialization failed.
其连接到了Amarok的代码:
import dbus
conn = dbus.SessionBus().get_object('org.kde.amarok','/Player')
你知道我应该怎么办通过DBUS连接到Amarok的?
非常感谢您的帮助!
更新: 我给你有关配置一些额外的信息:
的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
代码的应用程序(指数.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]
没有人?到目前为止我没有找到答案 – stuudent 2011-03-24 02:41:09