Luca Rosignoli replied to the topic 'Build a python-dbus script' in the forum. 2 years ago

Ok, very good!

I finally undestrand a little bit better how the DBus interfaces works.

hoping to do something pleasing, i post here a simple code to reach the focus section of ekos and print its introspection

import dbus
import time

bus = dbus.SessionBus()
kstars = bus.get_object("org.kde.kstars", "/KStars")

ekos_obj=bus.get_object("org.kde.kstars", "/KStars/Ekos")
e_iface=dbus.Interface(ekos_obj,"org.kde.kstars.Ekos")
e_iface.start()

time.sleep(1.0)

focus = bus.get_object("org.kde.kstars", "/KStars/Ekos/Focus")

print(focus.Introspect())

One thing that seems obvious but that I hadn’t realized before, was that the functionality that you want reach through DBus must be already active. I thought instead that it was enough to be present in the functionality of the parent program.

If I will meet another problem I will post here, hoping to make this discussion another help for the scripting and development section of Kstars/Ekos.

Luca.

Read More...