tango_simlib modules¶
- tango_simlib modules
- tango_simlib.main module
- tango_simlib.model module
- tango_simlib.quantities module
- tango_simlib.sim_sdd_xml_parser module
- tango_simlib.sim_test_interface module
- tango_simlib.sim_xmi_parser module
- tango_simlib.simdd_json_parser module
- tango_simlib.tango_launcher module
- tango_simlib.tango_sim_generator module
- tango_simlib.testutils module
- tango_simlib.helper_module module
tango_simlib.main module¶
tango_simlib.model module¶
-
class
tango_simlib.model.
Model
(name, start_time=None, min_update_period=0.99, time_func=<built-in function time>)[source]¶ Bases:
object
Tango Device main model with quantities and actions
- name : str
- Model name identifier
- start_time : float
- Time at instantiation of the model
- min_update_period : float
- Minimun update period of the quantites in the model
- time_func : time function
- Function that return current time i.e. time.time
-
set_sim_action
(name, handler)[source]¶ Add an action handler function
- name : str
- Name of the action
- handler : callable(model_instance, action_args)
- Callable that handles action (name). Is called with the model instance as the first parameter.
-
set_test_sim_action
(name, handler)[source]¶ Add an action handler function
- name : str
- Name of the action
- handler : callable(model_instance, action_args)
- Callable that handles action (name). Is called with the model instance as the first parameter.
-
setup_sim_quantities
()[source]¶ Set up self.sim_quantities with simulated quantities
Subclasses should implement this method. Should place simulated quantities in self.sim_quantities dict. Keyed by name of quantity, value must be instances satisfying the
quantites.Quantity
interface.- Must use self.start_time to set initial time values.
- Must call super method after setting up sim_quantities
-
class
tango_simlib.model.
PopulateModelActions
(parser_instance, tango_device_name, model_instance=None)[source]¶ Bases:
object
Used to populate/update model actions
Populates the model actions using the data from the TANGO device information captured in the POGO generated xmi file.
- command_info : dict
- A dictionary of all the device commands together with their metadata specified in the POGO generated XMI file. The key represents the name of the command and the value is a dictionary of all the attribute’s metadata.
- sim_model : Model instance
- An instance of the Model class which is used for simulation of simple attributes and/or commands.
-
generate_action_handler
(action_name, action_output_type, actions=None)[source]¶ Generates and returns an action handler to manage tango commands
- action_name : str
- Name of action handler to generate
- action_output_type : PyTango._PyTango.CmdArgType
- Tango command argument type
- actions : list
- List of actions that the handler will provide
- action_handler : function
- action handler, taking command input argument in case of tango commands with input arguments.
-
class
tango_simlib.model.
PopulateModelQuantities
(parser_instance, tango_device_name, sim_model=None)[source]¶ Bases:
object
Used to populate/update model quantities
Populates the model quantities using the data from the TANGO device information captured in the POGO generated xmi file.
- parser_instance : Parser instance
- The Parser object which reads an xmi/xml/json file and parses it into device attributes, commands, and properties.
- sim_model : Model instance
- An instance of the Model class which is used for simulation of simple attributes.
-
setup_sim_quantities
()[source]¶ Set up self.sim_quantities from Model with simulated quantities
Places simulated quantities in sim_quantities dict. Keyed by name of quantity, value must be instances satifying the
quantities.Quantity
interface- Must use self.start_time to set initial time values.
- Must call super method after setting up sim_quantities
-
sim_attribute_quantities
(min_bound, max_bound, max_slew_rate, mean, std_dev)[source]¶ Simulate attribute quantities with a Guassian value distribution
- min_value : float
- minimum attribute value to be simulated
- max_value : float
- maximum attribute value to be simulated
- max_slew_rate : float
- maximum changing rate of the simulated quantities between min and max values
- mean : float
- average value of the simulated quantity
- std_dev : float
- starndard deviation value of the simulated quantity
- sim_attribute_quantities : dict
- Dict of Gaussian simulated quantities
-
exception
tango_simlib.model.
SimModelException
(message)[source]¶ Bases:
exceptions.Exception
tango_simlib.quantities module¶
-
class
tango_simlib.quantities.
ConstantQuantity
(start_value=None, start_time=None, meta=None)[source]¶ Bases:
tango_simlib.quantities.Quantity
A quantity that does not change unless explicitly set
-
class
tango_simlib.quantities.
GaussianSlewLimited
(mean, std_dev, max_slew_rate=inf, meta=None, min_bound=-inf, max_bound=inf, start_value=None, start_time=None)[source]¶ Bases:
tango_simlib.quantities.Quantity
A Gaussian random variable a slew-rate limit and clipping
- mean : float
- Gaussian mean value
- std_dev : float
- Gaussian standard deviation
- max_slew_rate : float
- Maximum quantity slew rate in amount per second. Random values will be clipped to satisfy this condition.
- min_bound : float
- Minimum quantity value, random values will be clipped if needed.
- max_bound : float
- Maximum quantity value, random values will be clipped if needed.
-
adjustable_attributes
= frozenset([‘last_update_time’, ‘max_slew_rate’, ‘last_val’, ‘min_bound’, ‘max_bound’, ‘std_dev’, ‘mean’])¶
-
class
tango_simlib.quantities.
Quantity
(start_value=None, start_time=None, meta=None)[source]¶ Bases:
object
Attributes that should be adjustable via a simulation control interface
- start_time : float
- The initial time when a quantity is updated.
- start_value : float
- The initial value of a quantity.
- meta : dict
- This data structure must contain all the attribute desciption data of all quantities that represent tango device simulator attributes. List of all available tango attibute description data: abs_change, archive_abs_change, archive_period, archive_rel_change, label, max_alarm, max_value, max_warning, min_alarm, min_value, delta_t, delta_val, description, display_unit, format, min_warning, period, rel_change e.g. meta=dict(label=”Outside Temperature”, dtype=float) TODO (AR) 2016-07-27 : Ideally these properties should not be TANGO specific as is at the moment.
Subclasses should add all the attributes to this set that users should be able to adjust via a user interface at simulation runtime, also initialise the last_val attribute with the initial quantity value.
-
adjustable_attributes
= frozenset([‘last_update_time’, ‘last_val’])¶
tango_simlib.sim_sdd_xml_parser module¶
This module performs the parsing of the SKA Self-Description Data XML schema file generated from the DSL.
-
class
tango_simlib.sim_sdd_xml_parser.
SDDParser
[source]¶ Bases:
object
Parses the SDD XML file generated from DSL.
monitoring_points: dict
commands: dict
-
extract_command_info
(cmd_info)[source]¶ Extracts all the information of the XML element ‘CommandList’
cmd_info: xml.etree.ElementTree.Element e.g.
- <CommandList>
- <Command>
<CommandID></CommandID> <CommandName>ON</CommandName> <CommandDescription></CommandDescription> <CommandType></CommandType> <Timeout></Timeout> <MaxRetry></MaxRetry> <TimeForExecution></TimeForExecution> <AvailableInModes>
<Mode></Mde> <Mode></Mode></AvailableInModes> <CommandParameters></CommandParameters> <ResponseList>
- <Response>
<ResponseID></ResponseID> <ResponseName>RES_ON</ResponseName> <ResponseType></ResponseType> <ResponseParameters>
- <Parameter>
- <ParameterID></ParameterID> <ParameterName>msg</ParameterName> <ParameterValue></ParameterValue>
</Parameter>
</ResponseParameters>
</Response>
</ResponseList>
</Command>
</CommandList>
- cmds: dict
A dictionary of all the commands and their metadata. e.g. {
- ‘cmd_name’: {
‘CommandID’: ”, ‘Command_Name: ”, ‘CommandDescription: ”, ‘CommandType: ”, ‘Timeout’: ”, ‘MaxRetry’: ”, ‘TimeForExecution’: ”, ‘AvailableInModes’: {}, ‘CommandParameters’: {}, ‘ResponseList’: {
- ‘response_name’: {
‘ResponseID’: ”, ‘ResponseName’: ”, ‘ResponseType’: ”, ‘ResponseDescription’: ”, ‘ResponseParameters’: {
- ‘parameter_name’: {
- ‘ParameterID’: ”, ‘ParameterName’: ”, ‘ParameterValue’: ”, }
}
}
}
}
}
-
extract_monitoring_point_info
(mp_info)[source]¶ Extracts all the information of the XML element ‘MonitoringPointsList’
- mp_info: xml.etree.ElementTree.Element
e.g. <MonitoringPointsList>
- <MonitoringPoint id=”” name=”Temperature” mandatory=”TRUE/FALSE”>
<Description></Description> <DataType>float</DataType> <Size>0</Size> <RWType></RWType> <PossibleValues>
<PossibleValue></PossibleValue> <PossibleValue></PossibleValue></PossibleValues> <ValueRange>
<MinValue>-10</MinValue> <MaxValue>55</MaxValue></ValueRange> <SamplingFrequency>
<DefaultValue></DefaultValue> <MaxValue></MaxValue></SamplingFrequency> <LoggingLevel></LoggingLevel>
</MonitoringPoint>
</MonitoringPointsList>
- dev_mnt_pts: dict
A dictionary of all the element’s commands and their metadata. e.g. {
- ‘monitoring_pt_name’: {
‘id’: ”, ‘name’: ”, ‘Description’: ”, ‘DataType’: ”, ‘Size’: ”, ‘RWType’: ”, ‘PossibleValues’: [], ‘ValueRange’: {
‘MinValue’: ”, ‘MaxValue’: ”, },- ‘SamplingFrequecy’: {
- ‘DefaultValue’: ”, ‘MaxValue’: ”, }
‘LoggingLevel’ :” }
}
-
tango_simlib.sim_test_interface module¶
@author MeerKAT CAM team <cam@ska.ac.za>
tango_simlib.sim_xmi_parser module¶
Simlib library generic simulator generator utility to be used to generate an actual TANGO device that exhibits the behaviour defined in the data description file. @author MeerKAT CAM team <cam@ska.ac.za>
-
class
tango_simlib.sim_xmi_parser.
XmiParser
[source]¶ Bases:
object
-
class_properties
= None¶ Data structure format is a list containing class property info in a dict
e.g. [{
- “classProperties”: {
- “type”: DevString, “mandatory”: “true”, “description”: “Path to the pogo generate xmi file”, “name”: “sim_xmi_description_file”, “DefaultPropValue”: “<any object>”
}
}]
-
device_attributes
= None¶ The Data structure format is a list containing attribute info in a dict
e.g. [{
- “attribute”: {
- “displayLevel”: “OPERATOR”, “maxX”: “”, “maxY”: “”, “attType”: “Scalar”, “polledPeriod”: “1000”, “dataType”: DevDouble, “isDynamic”: “true”, “rwType”: “READ”, “allocReadMember”: “true”, “name”: “temperature”
}, “eventCriteria”: {
“relChange”: “10”, “absChange”: “0.5”, “period”: “1000”}, “evArchiveCriteria”: {
“relChange”: “10”, “absChange”: “0.5”, “period”: “1000”}, “properties”: {
“description”: “Current temperature outside near the telescope.”, “deltaValue”: “”, “maxAlarm”: “50”, “maxValue”: “51”, “minValue”: “-10”, “standardUnit”: “”, “minAlarm”: “-9”, “maxWarning”: “45”, “unit”: “Degrees Centrigrade”, “displayUnit”: “”, “format”: “”, “deltaTime”: “”, “label”: “Outside Temperature”, “minWarning”: “-5”}
}]
-
device_commands
= None¶ The Data structure format is a list containing command info in a dict
e.g. [{
“name”: “On”, “arginDescription”: “”, “arginType”: tango._tango.CmdArgType.DevVoid, “argoutDescription”: “ok | Device ON”, “argoutType”: tango._tango.CmdArgType.DevString, “description”: “Turn On Device”}]
-
device_properties
= None¶ Data structure format is a list containing device property info in a dict
e.g. [{
- “deviceProperties”: {
- “type”: DevString, “mandatory”: “true”, “description”: “Path to the pogo generate xmi file”, “name”: “sim_xmi_description_file”, “DefaultPropValue”: “<any object>”
}
}]
-
extract_attributes_description_data
(description_data)[source]¶ Extract attribute description data from the xmi tree element.
- description_data: xml.etree.ElementTree.Element
XMI tree element with attribute data
Expected element tag(s) are (i.e. description_data.tag) ‘dynamicAttributes’
description_data.find(‘properties’).attrib contains {
“description”: “”, “deltaValue”: “”, “maxAlarm”: “”, “maxValue”: “”, “minValue”: “”, “standardUnit”: “”, “minAlarm”: “”, “maxWarning”: “”, “unit”: “”, “displayUnit”: “”, “format”: “”, “deltaTime”: “”, “label”: “”, “minWarning”: “”}
and
description_data.attrib contains {
“maxX”: “”, “maxY”: “”, “attType”: “Scalar”, “polledPeriod”: “0”, “displayLevel”: “OPERATOR”, “isDynamic”: “false”, “rwType”: “WRITE”, “allocReadMember”: “false”, “name”: “Constant”}
description_data.find(‘eventCriteria’).attrib contains {
“relChange”: “10”, “absChange”: “0.5”, “period”: “1000”}
description_data.find(‘evArchiveCriteria’).attrib contains {
“relChange”: “10”, “absChange”: “0.5”, “period”: “1000”}
- attribute_data: dict
- Dictionary of all attribute data required to create a tango attribute
-
extract_command_description_data
(description_data)[source]¶ Extract command description data from the xmi tree element.
- description_data: xml.etree.ElementTree.Element
XMI tree element with command data, where expected element tag(s) are (i.e. description_data.tag) [‘argin’, ‘argout’] and description_data.attrib contains {
“description”: “Turn On Device”, “displayLevel”: “OPERATOR”, “isDynamic”: “false”, “execMethod”: “on”, “polledPeriod”: “0”, “name”: “On”}
- command_data: dict
- Dictionary of all the command data required to create a tango command
-
extract_property_description_data
(description_data, property_group)[source]¶ Extract device/class property description data from the xmi tree element.
- description_data: xml.etree.ElementTree.Element
XMI tree element with device property data
Expected element tag(s) are (i.e. description_data.tag) [‘DefaultPropValue’]
description_data.attrib contains {
‘description’: ”, ‘name’: ‘katcp_address’, ‘type’: ”}
- property_group: str
- A string representing a group to which the property belongs to, either device properties or class properties.
- device_property_data: dict
- Dictionary of all device property data required to create a tango device property
-
get_reformatted_cmd_metadata
()[source]¶ Converts the device_commands data structure into a dictionary that makes searching easier.
- commands : dict
A dictionary of all the device commands together with their metadata specified in the POGO generated XMI file. The key represents the name of the command and the value is a dictionary of all the attribute’s metadata.
e.g. { ‘cmd_name’: {cmd_properties}
}
-
get_reformatted_device_attr_metadata
()[source]¶ Converts the device_attributes data structure into a dictionary to make searching easier.
- attributes: dict
A dictionary of all the device attributes together with their metadata specified in the POGO generated XMI file. The key represents the name of the attribute and the value is a dictionary of all the attribute’s metadata.
e.g. {‘input_comms_ok’: {
‘abs_change’: ”, ‘archive_abs_change’: ”, ‘archive_period’: ‘1000’, ‘archive_rel_change’: ”, ‘data_type’: PyTango._PyTango.CmdArgType.DevBoolean, ‘data_format: PyTango._PyTango.AttrDataFormat.SCALAR, ‘delta_t’: ”, ‘delta_val’: ”, ‘description’: ‘Communications with all weather sensors are nominal.’, ‘display_unit’: ”, ‘event_period’: ‘1000’, ‘format’: ”, ‘label’: ‘Input communication OK’, ‘max_alarm’: ”, ‘max_value’: ”, ‘max_warning’: ”, ‘min_alarm’: ”, ‘min_value’: ”, ‘min_warning’: ”, ‘name’: ‘input_comms_ok’, ‘period’: ‘1000’, ‘rel_change’: ”, ‘standard_unit’: ”, ‘unit’: ”, ‘writable’: ‘READ’, ‘enum_labels’: []}, # If attribute data type is DevEnum}
-
get_reformatted_properties_metadata
(property_group)[source]¶ Creates a dictionary of the device properties and their metadata.
- property_group: str
- A string representing a group to which the property belongs to, either device properties or class properties (deviceProperties or classProperties).
- device_properties: dict
A dictionary of all the device properties together with their metadata specified in the POGO generated XMI file. The keys represent the name of the device property and the value is a dictionary of all the property’s metadata.
e.g. { ‘device_property_name’ : {device_property_metadata}}
- property_group: str
- A string representing a group to which the property belongs to, either device properties or class properties.
-
parse
(sim_xmi_file)[source]¶ Read simulator description data from xmi file into self.device_properties
Stores all the simulator description data from the xmi tree into appropriate attribute, command and device property data structures. Loops through the xmi tree class elements and appends description information of dynamic/attributes into self.device_attributes, commands into self.device_commands, and device_properties into self.device_properties.
- sim_xmi_file: str
- Name of simulator descrition data file
- Data structures, are type list with dictionary elements keyed with description data and values must be the corresponding data value.
-
tango_simlib.simdd_json_parser module¶
This module performs the parsing of the Simulator Description Datafile, containing the information needed to instantiate a useful device simulator. @author MeerKAT CAM team <cam@ska.ac.za>
-
class
tango_simlib.simdd_json_parser.
SimddParser
[source]¶ Bases:
object
-
get_device_data_components_dict
(elements, element_type)[source]¶ Extract description data from the simdd json element
- elements: list
- List of device data elements with items in unicode format
e.g. [{
- “basicAttributeData”: {
“name”: “temperature”, “unit”: “Degrees Centrigrade”, “label”: “Outside Temperature”, “description”: “Current temperature outside near the telescope.”, “data_type”: “Double”, “data_format”: “”, “delta_t”: “1000”, “delta_val”: “0.5”, “data_shape”: {
“max_dim_x”: “1”, “max_dim_y”: “0”}, “attributeErrorChecking”: {
“min_value”: “-10”, “max_value”: “51”, “min_alarm”: “-9”, “max_alarm”: “50”}, “attributeInterlocks”: {
“writable”: “READ”}, “dataSimulationParameters”: {
“quantity_simulation_type”: “GaussianSlewLimited”, “min_bound”: “-10”, “max_bound”: “50”, “mean”: “25”, “max_slew_rate”: “1”, “update_period”: “1”, “std_dev”: “5”}, “attributeControlSystem”: {
“display_level”: “OPERATOR”, “period”: “1000”, “EventSettings”: {
- “eventArchiveCriteria”: {
- “archive_abs_change”: “0.5”, “archive_period”: “1000”, “archive_rel_change”: “10”
}, “eventCrateria”: {
“abs_change”: “0.5”, “event_period”: “1000”, “rel_change”: “10”}
}
}
}
}]
- device_dict: dict
- device data dictionary in the format of self._device_attributes or self._device_commands
-
get_reformated_data
(sim_device_element_info, element_type)[source]¶ Helper function for flattening the data dicts to be more readable
- sim_device_info: dict
- Data element Dict
e.g. {“basicAttributeData”: {
“name”: “temperature”, “unit”: “Degrees Centrigrade”, “label”: “Outside Temperature”, “description”: “Current temperature outside near the telescope.”, “data_type”: “Double”, “data_format”: “”, “delta_t”: “1000”, “delta_val”: “0.5”, “data_shape”: {
“max_dim_x”: “1”, “max_dim_y”: “0”}, “attributeErrorChecking”: {
“min_value”: “-10”, “max_value”: “51”, “min_alarm”: “-9”, “max_alarm”: “50”}, “attributeInterlocks”: {
“writable”: “READ”}, “dataSimulationParameters”: {
‘quantity_simulation_type’: ‘GaussianSlewLimited’, “min_bound”: “-10”, “max_bound”: “50”, “mean”: “25”, “max_slew_rate”: “1”, “update_period”: “1”}, “attributeControlSystem”: {
“display_level”: “OPERATOR”, “period”: “1000”, “EventSettings”: {
- “eventArchiveCriteria”: {
- “archive_abs_change”: “0.5”, “archive_period”: “1000”, “archive_rel_change”: “10”
}, “eventCrateria”: {
“abs_change”: “0.5”, “event_period”: “1000”, “rel_change”: “10”}
}
}
}
}
- items : dict
- A more formatted and easy to read dictionary
e.g.
- {
- ‘abs_change’: ‘0.5’, ‘archive_abs_change’: ‘0.5’, ‘archive_period’: ‘1000’, ‘archive_rel_change’: ‘10’, ‘data_format’: ”, ‘data_type’: PyTango._PyTango.CmdArgType.DevDouble, ‘delta_t’: ‘1000’, ‘delta_val’: ‘0.5’, ‘description’: ‘Current temperature outside near the telescope.’, ‘display_level’: ‘OPERATOR’, ‘event_period’: ‘1000’, ‘label’: ‘Outside Temperature’, ‘max_alarm’: ‘50’, ‘max_bound’: ‘50’, ‘max_dim_x’: ‘1’, ‘quantity_simulation_type’: ‘GaussianSlewLimited’, ‘max_dim_y’: ‘0’, ‘max_slew_rate’: ‘1’, ‘max_value’: ‘51’, ‘mean’: ‘25’, ‘min_alarm’: ‘-9’, ‘min_bound’: ‘-10’, ‘min_value’: ‘-10’, ‘name’: ‘temperature’, ‘period’: ‘1000’, ‘rel_change’: ‘10’, ‘unit’: ‘Degrees Centrigrade’, ‘update_period’: ‘1’, ‘writable’: ‘READ’
}
-
get_reformatted_cmd_metadata
()[source]¶ Returns a more formatted command data structure in a format of dict
-
get_reformatted_device_attr_metadata
()[source]¶ Returns a more formatted attribute data structure in a format of dict
-
get_reformatted_override_metadata
()[source]¶ Returns more formatted device override info data structure in dict format
-
get_reformatted_properties_metadata
(property_group)[source]¶ Returns a more formatted device prop data structure in a format of dict
-
parse
(simdd_json_file)[source]¶ Read simulator description data from json file into self._device_properties
Stores all the simulator description data from the json file into appropriate attribute, command and device property data structures. Loops through the json object elements and updates description information of dynamic/attributes into self._device_attributes, commands into self._device_commands, and device_properties into self._device_properties.
- simdd_json_file: str
- Name of simulator descrition data file
- Data structures, are type dict with dictionary elements keyed with element name and values must be the corresponding data value.
-
tango_simlib.tango_launcher module¶
Utility to help launch a TANGO device in a KATCP eco-system
Helps by auto-registering a TANGO device if needed
tango_simlib.tango_sim_generator module¶
Simlib library generic simulator generator utility to be used to generate an actual TANGO device that exhibits the behaviour defined in the data description file. @author MeerKAT CAM team <cam@ska.ac.za>
-
tango_simlib.tango_sim_generator.
configure_device_model
(sim_data_file=None, test_device_name=None)[source]¶ In essence this function should get the xmi file, parse it, take the attribute and command information, populate the model quantities and actions to be simulated and return that model.
- sim_datafile : list
- A list of direct paths to either xmi/xml/json files.
- test_device_name : str
- A TANGO device name. This is used for running tests as we want the model instance and the device name to have the same name.
model : model.Model instance
-
tango_simlib.tango_sim_generator.
generate_device_server
(server_name, sim_data_files, directory=”)[source]¶ Create a tango device server python file
- server_name: str
- Tango device server name
- sim_data_files: list
- A list of direct paths to either xmi/xml/json data files.
-
tango_simlib.tango_sim_generator.
get_device_class
(sim_data_files)[source]¶ Get device class name from specified xmi/simdd description file
- sim_data_files: list
- A list of direct paths to either xmi/xml/json data files.
- klass_name: str
- Tango device class name
-
tango_simlib.tango_sim_generator.
get_parser_instance
(sim_datafile)[source]¶ This method returns an appropriate parser instance to generate a Tango device
- sim_datafile : str
- A direct path to the xmi/xml/json file.
- parser_instance: Parser instance
- The Parser object which reads an xmi/xml/json file and parses it into device attributes, commands, and properties.
-
tango_simlib.tango_sim_generator.
get_tango_device_server
(model, sim_data_files)[source]¶ Declares a tango device class that inherits the Device class and then adds tango commands.
- model: model.Model instance
- Device model instance
- sim_data_files: list
- A list of direct paths to either xmi/xml/json data files.
- TangoDeviceServer : PyTango.Device
- Tango device that has the results of the translated KATCP server
tango_simlib.testutils module¶
-
class
tango_simlib.testutils.
ClassCleanupUnittestMixin
[source]¶ Bases:
object
Implement class-level setup/deardown semantics that emulate addCleanup()
Subclasses can define a setUpClassWithCleanup() method that wraps addCleanup such that cls.addCleanup() can be used to add cleanup methods that will be called at class tear-down time.
-
classmethod
addCleanupClass
(function, *args, **kwargs)[source]¶ Add a cleanup that will be called at class tear-down time
-
classmethod
doCleanupsClass
()[source]¶ Run class-level cleanups registered with cls.addCleanupClass()
-
classmethod
setUpClass
()[source]¶ Call setUpClassWithCleanup with cls.addCleanup for class-level cleanup
Any exceptions raised during cls.setUpClassWithCleanup will result in the cleanups registered up to that point being called before logging the exception with traceback.
-
classmethod
setUpClassWithCleanup
()[source]¶ Do class-level setup and ensure that cleanup functions are called
It is inteded that subclasses override this class method
In this method calls to cls.addCleanup is forwarded to cls.addCleanupClass, which means callables registered with cls.addCleanup() is added to the class-level cleanup function stack.
-
classmethod
-
tango_simlib.testutils.
cleanup_tempdir
(test_instance, *mkdtemp_args, **mkdtemp_kwargs)[source]¶ Return filname of a new tempfile and add cleanup callback to test_instance.
Will not raise an error if the directory is not present when trying to delete.
Extra args and kwargs are passed on to the tempfile.mkdtemp call
-
tango_simlib.testutils.
cleanup_tempfile
(test_instance, unlink=False, *mkstemp_args, **mkstemp_kwargs)[source]¶ Return filename of a new tempfile and add cleanup callback to test_instance.
Will not raise an error if the file is not present when trying to delete.
If unlink=True the actual temp file will be deleted immediately. This is useful if you want to check behaviour in absence of a named file.
Extra args and kwargs are passed on to the tempfile.mkstemp call.
-
tango_simlib.testutils.
disable_attributes_polling
(test_case, device_proxy, device_server, attributes)[source]¶ Disable polling for a tango device server, en re-eable at end of test
-
tango_simlib.testutils.
set_attributes_polling
(test_case, device_proxy, device_server, poll_periods)[source]¶ Set attribute polling and restore after test
- test_case : unittest.TestCase instance
- Unit test case class instance
- device_proxy : PyTango.DeviceProxy instance
- The Tango device proxy instance
- device_server : PyTango.Device instance
- The instance of the device class device_proxy is talking to
- poll_periods : dict {“attribute_name” : poll_period}
- poll_poriod in milliseconds as per Tango APIs, 0 or falsy to disable polling.
- restore_polling : function
- This function can be used to restore polling if it is to happen before the end of the test. Should be idempotent if only one set_attributes_polling() is called per test.
tango_simlib.helper_module module¶
-
tango_simlib.helper_module.
append_device_to_db_file
(server, instance, device, db_file_name, tangoclass=None, properties={})[source]¶ Generate a database file corresponding to the given arguments.
-
tango_simlib.helper_module.
get_server_name
()[source]¶ Gets the TANGO server name from the command line arguments
- server_name : str
- tango device server name
Extract the Tango server_name or equivalent executable (i.e.sim_xmi_parser.py -> sim_xmi_parser or /usr/local/bin/mkat-tango-katcpdevice2tango-DS -> mkat-tango-katcpdevice2tango-DS) from the command line arguments passed, where sys.argv[1] is the server instance.