fandango.servers module

Description

@if gnuheader

## file : servers.py ## ## description : see below ## ## project : Tango Control System ## ## $Author: Sergi Rubio Manrique, srubio@cells.es $ ## ## $Revision: 2008 $ ## ## copyleft : ALBA Synchrotron Controls Section, CELLS ## Bellaterra ## Spain ## ############################################################################# ## ## This file is part of Tango Control System ## ## Tango Control System is free software; you can redistribute it and/or ## modify it under the terms of the GNU General Public License as published ## by the Free Software Foundation; either version 3 of the License, or ## (at your option) any later version. ## ## Tango Control System is distributed in the hope that it will be useful, ## but WITHOUT ANY WARRANTY; without even the implied warranty of ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ## GNU General Public License for more details. ## ## You should have received a copy of the GNU General Public License ## along with this program; if not, see <http://www.gnu.org/licenses/>. ########################################################################### @endif

Classes

ComposersDict

class fandango.servers.ComposersDict(pattern='', klass='', devs_list='', servers_list='', hosts='', loadAll=False, log='WARNING', logger=None, tango_host='')[source]
get_attributes(device=None, attribute=None)[source]

Both device and attribute are regexps

get_property(*args)[source]

get_property(property) or get_property(device_regexp,property)

load_attributes()[source]

Loads device/attribute formulas from the database

set_property(*args)[source]

set_property(property,value) or set_property(device_regexp,property,value)

TServer

class fandango.servers.TServer(name='', host='', parent=None)[source]

Class used by ServerDict to manage TangoDeviceServer admin devices.

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_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.

update_level(host, level=0)[source]

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

ServersDict

class fandango.servers.ServersDict(pattern='', klass='', devs_list='', servers_list='', hosts='', loadAll=False, log='WARNING', logger=None, tango_host='')[source]

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='', as_text=False)[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]

get the status of Servers

get_server_level(server_name)[source]

It executes a DbGetServerInfo command in dbserver device.

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

It loads all device servers declared in Tango database

load_by_class(klass)[source]

Initializes the ServersDict using all the devices from a given class

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_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]

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.

Astor

fandango.servers.Astor

alias of ServersDict


raw autodoc

fandango.servers.Astor

alias of ServersDict

class fandango.servers.ComposersDict(pattern='', klass='', devs_list='', servers_list='', hosts='', loadAll=False, log='WARNING', logger=None, tango_host='')[source]

Bases: fandango.servers.ServersDict

get_attributes(device=None, attribute=None)[source]

Both device and attribute are regexps

get_formula(attribute)[source]
get_property(*args)[source]

get_property(property) or get_property(device_regexp,property)

load_attributes()[source]

Loads device/attribute formulas from the database

read_attribute(attribute)[source]
read_attribute_value(attribute)[source]
set_formula(attribute, formula, update=True)[source]
set_property(*args)[source]

set_property(property,value) or set_property(device_regexp,property,value)

update_attributes(dev, prop=None)[source]
class fandango.servers.ServersDict(pattern='', klass='', devs_list='', servers_list='', hosts='', loadAll=False, log='WARNING', logger=None, tango_host='')[source]

Bases: fandango.dicts.CaselessDict, fandango.objects.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_devices(host)[source]
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='', as_text=False)[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_host_starter(host)[source]
get_hosts_from_db(filt='*')[source]

Using a PyTango.Database proxy returns a list with all registered hosts in database.

get_report()[source]

get 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_class(klass)[source]

Initializes the ServersDict using all the devices from a given class

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]

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.servers.TServer(name='', host='', parent=None)[source]

Bases: fandango.objects.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.

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