![]() Registered Member ![]()
|
I've written a python plasmoid that gets akonadi events and displays them. I also wrote a python script to communicate with the plasmoid using dbus. It works perfectly when using plasmoidviewer but fails on the dbus.service.Object.__init__(self, busName, DBUS_PATH) when running as a plasmoid.
Could this be something in my code or is it possible this is not supported yet? benny |
![]() Administrator ![]()
|
Generally what works in Plasmoid viewer will work in Plasma itself. You may need to restart Plasma if changes have been made to the Plasmoid since it was first added to the desktop.
KDE Sysadmin
[img]content/bcooksley_sig.png[/img] |
![]() Registered Member ![]()
|
Thanks but that isn't the problem as I've rebooted 10 or more times since then. In fact, just upgraded from 4.3.1 to 4.3.2 and there is no change. What I require is more of a model for other scripts as in this combination of python script and plasmoid, I only need to get a list from the plasmoid and it isn't time critical. So I've bypassed the problem by using a 'try' on the dbus.service request and if it fails I write a pickle file. The python script also uses a 'try' when connecting to the interface and if it fails it gets the list from the pickle file. It all works. So there is no urgency in my problem.
It would be nice to have a model of the dbus working though. I have another plasmoid (a launcher and monitor) which uses dbus successfully. The difference between them is that the launcher plasmoid spawns a python script which establishes the dbus session, then sleeps for a second and then the launcher plasmoid just sends logging data to it. In the current plasmoid I am attempting to establish the dbus session to allow other scripts to connect to it. benny |
![]() Administrator ![]()
|
Are you using QDBus?
KDE Sysadmin
[img]content/bcooksley_sig.png[/img] |
![]() Registered Member ![]()
|
I'm confused now. Thought qdbus was a bash script tool. My plasmoid is written in python and following is the initial code and the basic parts that get it running:
############################################################### # use logfile if plasmoid works in plasmoidviewer but fails as a real plasmoid logFile = file('/drives/common/downloads/akonadiLog.txt', 'w') import dbus import gobject import dbus.service from dbus.mainloop.glib import DBusGMainLoop main_loop = DBusGMainLoop() # deprecated on python 2.6 # (fixed on karmic, so i patched it in /var/lib/python-support/python2.6/dbus/connection.py:242) bus = dbus.SessionBus(mainloop=main_loop) DBUS_NAME = "org.showAkonadiEvents" DBUS_PATH = "/org/showAkonadiEvents" myEvents = [] dbusActive = False pickleFile = file('/drives/common/downloads/pickleList.txt', 'w') class showAkonadidBus(dbus.service.Object): def __init__( self ): global dbusActive #Starting the dbus service. global bus try: busName = dbus.service.BusName(DBUS_NAME, bus=bus) except: print 'connection failed1' print >> logFile, 'connection failed1' logFile.flush() os.system('sleep 1') try: dbus.service.Object.__init__(self, busName, DBUS_PATH) #dbus.service.Object.__init__(self, dbus.SessionBus(), DBUS_PATH) print 'dbus service started' dbusActive= True except: print 'connection failed2' print >> logFile, 'connection failed2' logFile.flush() . . . class showAkonadi(plasmascript.Applet): def __init__(self,parent,args=None): plasmascript.Applet.__init__(self,parent) def init(self): # start dbus service showAkonadidBus() . . . . . # def CreateApplet(parent): global configFilename # name of the configuration file which lives in /home/user configFilename = "showAkonadi.cfg" return showAkonadi(parent) ############################################################### End up with 'connection failed2' when adding as a widget but it works correctly when run by plasmoidviewer |
![]() Administrator ![]()
|
QDBus is the namespace of a collection of Qt classes for interacting with DBus. It is also the name of a executable shipped by Qt as well.
See http://doc.trolltech.com/4.5/qtdbus.html
KDE Sysadmin
[img]content/bcooksley_sig.png[/img] |
Registered users: Bing [Bot], daret, Google [Bot], sandyvee, Sogou [Bot]