Re: [Tracker] runtime checking for tracker availability



2006/10/30, Mikkel Kamstrup Erlandsen <mikkel kamstrup gmail com>:
2006/10/30, Gabriel de Perthuis <tobutaz gmail com>:



* Ulrik Mikaelsson:
>
>     That would work on 98% of all systems, but I would really like a
>     completely generic test...

You could just go ahead and pretend to make a query, and check for nulls
or a particular exception in the DBus return values.

That way you'll pickup everything, even if tracker isn't in a standard
prefix (I do that since it's CVS, however I do have to copy the dbus
service file into a system dir).

Thanks for your replies everybody, but I still haven't exactly found what I was looking for. I think I better tell why exactly I want what I want.

I wan't to use it in the deskbar handler for tracker. Then the Tracker extension should show up in the list of available extensions if, and only if, trackerd is installed. I don't want to start trackerd just because it is shown in a list of available plugins...

About your suggestions:

pkg-config: That requires a tracker devel package to be installed. I only want to depend on the binaries.

$PATH: trackerd could be somewhere not in $PATH and still work normally since trackerd is started by dbus activation. I could look for the tracker-search executable then, but there's still guarantee that it is in $PATH (though it prolly would be on 99% of all systems).

Issueing a query: That would start trackerd f it is installed. I only want to *detect* if it is installed.


I finally figured this one out!

the following python scripts lists all activatable services:

START SCRIPT ===============
#!/usr/bin/python

import gobject
import dbus
if getattr(dbus, 'version', (0,0,0)) >= (0,41,0):
    import dbus.glib

def print_list_names_reply(list):
    print "Available services:"
    print str(list)   
    if "org.freedesktop.Tracker" in list:
        print "Tracker is installed"
    else:
        print "Tracker is not installed"
    mainloop.quit()

def print_error(e):
    print str(e)
    mainloop.quit()
   
bus = dbus.SessionBus()
proxy_obj = bus.get_object('org.freedesktop.DBus', '/org/freedesktop/DBus')
dbus_iface = dbus.Interface(proxy_obj, ' org.freedesktop.DBus')

#List all activatable services
dbus_iface.ListActivatableNames(reply_handler=print_list_names_reply, error_handler=print_error)

# Another option would be to list all running services (commented out for now)
#dbus_iface.ListNames(reply_handler=print_list_names_reply, error_handler=print_error)

mainloop = gobject.MainLoop()
mainloop.run()
END SCRIPT ===============
 
Cheers,
Mikkel



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]