fandango.scripts.servers_lite module¶
- fandango.scripts.servers_lite.Astor¶
alias of ServersDict
- class fandango.scripts.servers_lite.CaselessDefaultDict[source]¶
Bases: fandango.scripts.servers_lite.defaultdict_fromkey, taurus.core.util.containers.CaselessDict
a join venture between caseless and default dict This class merges the two previous ones. This declaration equals to:
CaselessDefaultDict = type(‘CaselessDefaultType’,(CaselessDict,defaultdict_fromkey),{})
- class fandango.scripts.servers_lite.ProxiesDict[source]¶
Bases: fandango.scripts.servers_lite.CaselessDefaultDict, taurus.core.util.object.Object
Dictionary that stores PyTango.DeviceProxies It is like a normal dictionary but creates a new proxy each time that the “get” method is called An earlier version is used in PyTangoArchiving.utils module This class must be substituted by Tau.Core.TauManager().getFactory()()
- class fandango.scripts.servers_lite.ServersDict(pattern='', klass='', devs_list='', servers_list='', hosts='', loadAll=False, tango_host='')[source]¶
Bases: taurus.core.util.containers.CaselessDict, taurus.core.util.object.Object
Dictionary of TServer classes indexed by server/instance names and loaded using wildcard expressions. Provides Jive/Astor functionality to a list of servers and allows to select/start/stop them by host, class or devices Its purpose is to allow generic start/stop of lists of Tango DeviceServers. This methods of selection provide new ways of search apart of Jive-like selection.
@attention Dict keys are lower case, to get the real server name each key returns a TServer object with a .name attribute
@par Usage: <pre> from fandango import Astor astor = Astor() astor.load_by_name(‘snap*’) astor.keys()
[‘snapmanager/1’, ‘snaparchiver/1’, ‘snapextractor/1’]server = astor[‘snaparchiver/1’] server.get_device_list()
[‘dserver/snaparchiver/1’, ‘archiving/snaparchiver/1’]astor.states() server.get_all_states()
dserver/snaparchiver/1: ON archiving/snaparchiver/1: ON- astor.get_device_host(‘archiving/snaparchiver/1’)
- palantir01
astor.stop_servers(‘snaparchiver/1’) astor.stop_all_servers() astor.start_servers(‘snaparchiver/1’,’palantir01’,wait=1000) astor.set_server_level(‘snaparchiver/1’,’palantir01’,4)
#Setting the polling of a device: server = astor[‘PySignalSimulator/bl11’] for dev_name in server.get_device_list():
dev = server.get_device(dev_name) attrs = dev.get_attribute_list() [dev.poll_attribute(attr,3000) for attr in attrs]</pre>
- check_servers_names(servers_list)[source]¶
Crosschecks the name of servers (case sensitive) with names retrieved by self.db.get_server_list()
- create_new_server(server_name, class_name, devs_list)[source]¶
It creates a new server in the database, using Jive’s like input.
- get_class_tree()[source]¶
@todo It returns a dictionary with the shape {‘class’:{‘server’:’device’}}
- get_db_device()[source]¶
It creates a proxy to a dbserver device declared inside sys/database/* branch of Tango database.
- get_device_class(device, server='')[source]¶
This method gets the server related to a device; if it is not in the dict gets it from the Database.
- get_device_host(device)[source]¶
This method gets the server related to a device; if it is not in the dict gets it from the Database.
- get_device_server(device)[source]¶
This method gets the server related to a device; if it is not in the dict gets it from the Database.
- get_device_tree()[source]¶
@todo It returns a dictionary with the shape {‘server’:{‘class’:’device’}}
- get_devs_from_db(dev_name)[source]¶
Using a PyTango.Database object returns a list of all devices matching the given name (domain*/family*/member*)
- get_host_level_servers(host, level=0, controlled=True)[source]¶
It inspects all pre-loaded servers and returns those controlled in the specified host and level.
- get_host_overview(host='')[source]¶
Returns a dictionary with astor-like information @param host the host to display @return {‘level’:{‘server’:{‘device’:State}}}
- get_host_servers(host)[source]¶
It inspects all pre-loaded servers and returns those controlled in the specified host.
- get_hosts_from_db(filt='*')[source]¶
Using a PyTango.Database proxy returns a list with all registered hosts in database.
- get_server_tree()[source]¶
@todo It returns a dictionary with the shape {‘server’:{‘class’:’device’}}
- kill_servers(servers_list)[source]¶
Kills a list of SERVERs by sending a HardKillServer to the Starter of their hosts.
- load_by_name(name)[source]¶
Initializes the dict with all the servers matching a given name (usually the executable name or class). A list of names is also possible.
- load_from_devs_list(devs_list)[source]¶
Initializes the dict using a list of devices; a query to the database is used to identify the server for each device.
- load_from_servers_list(servers_list, check=True)[source]¶
Initializes the dictionary using a list of server_names like [‘Exec/Instance’]
- refresh(servers=[], class_type='', asynch=True, timeout=60.0)¶
Updates states for given servers or the given class or all states if no class is given. The asynch argument controls if the state test is done in a separate thread for each server or not.
- restart_servers(servers_list=None, wait=5.0)[source]¶
Performs stop_servers followed by start_servers.
- set_server_level(server_name, host, level)[source]¶
It executes a DbPutServerInfo command in dbserver device.
- start_servers(servers_list=None, host='', wait=10.0)[source]¶
def server_Start(self,servers_list,host=’‘,wait=3): Starting a list of servers or a single one in the given host(argument could be an string or a list) The wait parameter forces to wait several seconds until the device answers to an State command. wait=0 performs no wait
- states(servers=[], class_type='', asynch=True, timeout=60.0)[source]¶
Updates states for given servers or the given class or all states if no class is given. The asynch argument controls if the state test is done in a separate thread for each server or not.
- stop_servers(servers_list=None)[source]¶
def server_Stop(self,dev_name): Stops a list of SERVERs by sending a Kill command to the admin device server. If the argument is a single device it will kill all the devices running in the same server!
- update_states(servers=[], class_type='', asynch=True, timeout=60.0)¶
Updates states for given servers or the given class or all states if no class is given. The asynch argument controls if the state test is done in a separate thread for each server or not.
- class fandango.scripts.servers_lite.TServer(name='', host='', parent=None)[source]¶
Bases: taurus.core.util.object.Object
Class used by ServerDict to manage TangoDeviceServer admin devices.
- classes¶
- get_proxy(device='')[source]¶
Returns a proxy to the given device; or the admin device if no device name is provided.
- fandango.scripts.servers_lite.add_new_device(server, klass, device)[source]¶
It can be used create any device, e.g. to create Starter in an init script add_new_device(‘Starter/$HOST’,’Starter’,’sys/admin/starter’)
- Then:
- ./Starter $HOST &
- class fandango.scripts.servers_lite.defaultdict_fromkey[source]¶
Bases: collections.defaultdict
Creates a dictionary with a default_factory function that creates new elements using key as argument. Usage : new_dict = defaultdict_fromkey(method); where method like (lambda key: return new_obj(key)) Each time that new_dict[key] is called with a key that doesn’t exist, method(key) is used to create the value Copied from PyAlarm device server @deprecated now in tau.core.utils.containers
- fandango.scripts.servers_lite.get_device_property(device, property)[source]¶
It returns device property value or just first item if value list has lenght==1