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()()

get(dev_name)[source]
get_admin(dev_name)[source]

Adds to the dictionary the admin device for a given device name and returns a proxy to it.

pop(dev_name)[source]

Removes a device from the dict

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_all_classes()[source]

It returns all classes appearing in servers.

get_all_devices()[source]

It returns all devices contained in servers.

get_all_hosts()[source]

It returns all hosts containing servers.

get_class_devices(klass)[source]

This method gets the devices related to a Class.

get_class_servers(klass)[source]

This method gets the servers related to a Class.

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_report()[source]

def server_Report(self): The status of Servers

get_server_level(server_name)[source]

It executes a DbGetServerInfo command in dbserver device.

get_server_states(update=False)[source]
get_server_tree()[source]

@todo It returns a dictionary with the shape {‘server’:{‘class’:’device’}}

kill_os(name)[source]
kill_servers(servers_list)[source]

Kills a list of SERVERs by sending a HardKillServer to the Starter of their hosts.

load_all_servers()[source]

It loads all device servers declared in Tango database

load_by_host(host)[source]

Initializes the dict with all the servers assigned to a given host.

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.

reset_server_level(server_name)[source]

It sets host = ‘’, mode = 0, level = 0

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_all_servers()[source]
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_all_servers()[source]
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_admin()[source]
get_admin_name()[source]

Returns the name of the server in the dserver/Server/Instance format.

get_all_states()[source]

Returns a dictionary with the individual states of the inner devices.

get_all_status()[source]

Returns a dictionary with the individual status of the inner devices.

get_classes(load=False)[source]
get_device(device)[source]
get_device_list()[source]

Returns a list of devices declared for this server.

get_proxy(device='')[source]

Returns a proxy to the given device; or the admin device if no device name is provided.

get_server_level()[source]

It returns initialized values, does not get values from database.

get_simple_name(name='')[source]

Returns the name of the server in the Server/Instance format.

get_starter_name()[source]

Returns the starter on charge of controlling this server.

init_from_db(db=None, load_devices=False)[source]

Gets name, classes, devices, host, level information from Tango Database.

ping(dname=None)[source]

Executes .ping() and .state() methods of the admin device.

set_state(state)[source]
update_level(host, level=0)[source]

It only initializes the values, does not get values from database.

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 &
fandango.scripts.servers_lite.clean_device_attribute_properties(device)[source]
fandango.scripts.servers_lite.clean_device_properties(device)[source]
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_database()[source]
fandango.scripts.servers_lite.get_database_device()[source]
fandango.scripts.servers_lite.get_device(device)[source]
fandango.scripts.servers_lite.get_device_attribute_properties(device, attribute)[source]
fandango.scripts.servers_lite.get_device_attributes(device)[source]
fandango.scripts.servers_lite.get_device_properties(device, flt='*')[source]
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

fandango.scripts.servers_lite.put_device_property(device, property, value=None)[source]
Two syntax are possible:
  • put_device_property(device,{property:value})
  • put_device_property(device,property,value)
fandango.scripts.servers_lite.remove_device_server(server, clean_db=True)[source]