How to get the list of all devices on the server in PyTango?

Feeling dumb not being able to find the answer to this question in the docs by myself, but how to get the list of all devices on the server in PyTango? Basically, I want to use DeviceProxy not with the devices which the paths I already know, but with all present devices.
Hi GTLeet

If I understand your question correctly, you want to query the Tango Database for all the devices available. The docs don't make it that obvious, so don't feel too dumb. For the running devices, this could be done using a method like this: https://pytango.readthedocs.io/en/latest/database.html#tango.Database.get_device_exported

For example:

from tango import Database

db = tango.Database()
devices = db.get_device_exported("*")


Once you have the list of devices you still need to use a new DeviceProxy to communicate with each one. Or you could build a Group object to communicate with them simultaneously.

On a more general note, there are also lots of useful utilities in fandango, which can do this and more.
https://github.com/tango-controls/fandango/blob/documentation/doc/recipes/CheckDevices.rst
It is using PyTango, of course, and some of the implementation details can be seen here: https://github.com/tango-controls/fandango/blob/982fff1309d81184506ea3d89f31c2aef99bf8de/fandango/tango/search.py#L61
You can see from that code what to do if you are also interested in devices that aren't running (exported).

Regards,
Anton
 
Register or login to create to post a reply.