Tango control subpackage (ska_tangoctl.tango_control)

Read and display Tango stuff.

class ska_tangoctl.tango_control.TangoControl(logger: Logger, cfg_data: Any, ns_name: str | None = None)[source]

Connect to Tango environment and retrieve information.

__del__() None[source]

Destructor.

__init__(logger: Logger, cfg_data: Any, ns_name: str | None = None)[source]

Get the show on the road.

Parameters:
  • logger – logging handle

  • cfg_data – configuration in JSON format

  • ns_name – K8S namespace

__weakref__

list of weak references to the object (if defined)

check_tango(tango_host: str, quiet_mode: bool, tango_port: int = 10000) int[source]

Check Tango host address.

Parameters:
  • tango_host – fully qualified domain name

  • quiet_mode – flag to suppress extra output

  • tango_port – port number

Returns:

error condition

get_tango_classes(fmt: str, evrythng: bool, quiet_mode: bool, tgo_name: str | None, reverse: bool) dict[source]

Read tango classes.

Parameters:
  • fmt – output format

  • evrythng – get commands and attributes regadrless of state

  • quiet_mode – flag for displaying progress bars

  • tgo_name – device name

  • reverse – sort in reverse order

Returns:

dictionary with devices

list_classes(fmt: str, evrythng: bool, quiet_mode: bool, reverse: bool, tgo_name: str | None) int[source]

Get device classes.

Parameters:
  • fmt – output format

  • evrythng – get commands and attributes regadrless of state

  • quiet_mode – flag for displaying progress bars

  • reverse – sort in reverse order

  • tgo_name – device name

Returns:

error condition

list_devices(file_name: str | None, fmt: str, evrythng: bool, uniq_cls: bool, quiet_mode: bool, reverse: bool, tgo_name: str | None) int[source]

List Tango devices.

Parameters:
  • file_name – output file name

  • fmt – output format

  • evrythng – get commands and attributes regadrless of state

  • uniq_cls – only show one device per class

  • quiet_mode – flag for displaying progress bars

  • reverse – sort in reverse order

  • tgo_name – device name

Returns:

error condition

read_input_file(input_file: str | None, tgo_name: str | None, dry_run: bool) None[source]

Read instructions from JSON file.

Parameters:
  • input_file – input file name

  • tgo_name – device name

  • dry_run – flag for dry run

read_input_files(json_dir: str, quiet_mode: bool = True) int[source]

Read info from JSON script files.

Parameters:
  • json_dir – directory with script files

  • quiet_mode – turn off progress bar

Returns:

error condition

run_info(uniq_cls: bool, file_name: str | None, fmt: str, evrythng: bool, quiet_mode: bool, reverse: bool, disp_action: int, tgo_name: str | None, tgo_attrib: str | None, tgo_cmd: str | None, tgo_prop: str | None, tango_port: int) int[source]

Read information on Tango devices.

Parameters:
  • uniq_cls – only read one device per class

  • file_name – output file name

  • fmt – output format

  • evrythng – get commands and attributes regadrless of state

  • quiet_mode – flag for displaying progress bars

  • reverse – sort in reverse order

  • disp_action – flag for output format

  • tgo_name – device name

  • tgo_attrib – attribute name

  • tgo_cmd – filter command name

  • tgo_prop – filter property name

  • tango_port – device port

Returns:

error condition

set_value(tgo_name: str, quiet_mode: bool, reverse: bool, tgo_attrib: str, tgo_value: str) int[source]

Set value for a Tango device.

Parameters:
  • tgo_name – device name

  • quiet_mode – flag for displaying progress bar

  • reverse – sort in reverse order

  • tgo_attrib – attribute name

  • tgo_value – attribute value

Returns:

error condition

usage(p_name: str) None[source]

Show how it is done.

Parameters:

p_name – executable name

class ska_tangoctl.tango_control.TangoJsonReader(logger: Logger, quiet_mode: bool, kube_namespace: str | None, devsdict: dict, file_name: str | None = None)[source]

Read JSON and print as markdown or text.

__del__() None[source]

Destructor.

__init__(logger: Logger, quiet_mode: bool, kube_namespace: str | None, devsdict: dict, file_name: str | None = None)[source]

Rock and roll.

Parameters:
  • logger – logging handle

  • quiet_mode – flag for displaying progress bar

  • kube_namespace – Kubernetes namespace

  • devsdict – dictionary with device data

  • file_name – output file name

__weakref__

list of weak references to the object (if defined)

print_html_all(html_body: bool) None[source]

Print the whole thing.

Parameters:

html_body – print HTML header and footer

print_html_quick(html_body: bool) None[source]

Print text in short form.

Parameters:

html_body – Flag to print HTML header and footer

print_markdown_all() None[source]

Print the whole thing.

print_txt_all() None[source]

Print the whole thing.

print_txt_quick() None[source]

Print text in short form.

class ska_tangoctl.tango_control.TangoScript(logger: Logger, input_file: int | str | bytes | PathLike[str] | PathLike[bytes], device_name: str | None, dry_run: bool)[source]

The classy Tango.

__init__(logger: Logger, input_file: int | str | bytes | PathLike[str] | PathLike[bytes], device_name: str | None, dry_run: bool)[source]

Read actions from file.

Raises:

Exception – error condition

Parameters:
  • logger – logging handle

  • input_file – input file

  • device_name – device name

  • dry_run – flag for dry run

__weakref__

list of weak references to the object (if defined)

read_write_attribute(attr_thing: str | None, attr_read: int | float | str | None, attr_write: int | float | str | None) int[source]

Read or write Tango attribute.

Parameters:
  • attr_thing – attribute name

  • attr_read – read value

  • attr_write – write value

Returns:

error condition

run() int[source]

Run the thing.

Returns:

error condition

run_command(cmd_thing: str, cmd_args: Any) int[source]

Run Tango command.

Parameters:
  • cmd_thing – command name

  • cmd_args – command arguments

Returns:

error condition

class ska_tangoctl.tango_control.TangoctlDevice(logger: Logger, quiet_mode: bool, reverse: bool, device: str, list_items: dict, tgo_attrib: str | None, tgo_cmd: str | None, tgo_prop: str | None)[source]

Compile a dictionary for a Tango device.

__del__() None[source]

Destructor.

__init__(logger: Logger, quiet_mode: bool, reverse: bool, device: str, list_items: dict, tgo_attrib: str | None, tgo_cmd: str | None, tgo_prop: str | None)[source]

Iniltialise the thing.

Parameters:
  • logger – logging handle

  • quiet_mode – flag for displaying progress bars

  • reverse – sort in reverse order

  • device – device name

  • list_items – attributes, commands or properties in list output

  • tgo_attrib – attribute filter

  • tgo_cmd – command filter

  • tgo_prop – property filter

check_for_attribute(tgo_attrib: str | None) list[source]

Filter by attribute name.

Parameters:

tgo_attrib – attribute name

Returns:

list of device names matched

check_for_command(tgo_cmd: str | None) list[source]

Filter by command name.

Parameters:

tgo_cmd – command name

Returns:

list of device names matched

check_for_property(tgo_prop: str | None) list[source]

Filter by command name.

Parameters:

tgo_prop – property name

Returns:

list of device names matched

make_json(delimiter: str = ',') dict[source]

Convert internal values to JSON.

Parameters:

delimiter – field are seperated by this

Returns:

dictionary

print_html_all(html_body: bool) None[source]

Print full HTML report.

Parameters:

html_body – Flag to print HTML header and footer

print_html_quick(html_body: bool) None[source]

Print shortened HTML report.

Parameters:

html_body – Flag to print HTML header and footer

print_list_attribute(lwid: int) None[source]

Print list of devices with attribute.

Parameters:

lwid – line width

print_list_command(lwid: int) None[source]

Print list of devices with command.

Parameters:

lwid – line width

print_list_property(lwid: int) None[source]

Print list of devices with property.

Parameters:

lwid – line width

print_markdown_all() None[source]

Print full HTML report.

print_txt_all() None[source]

Print full HTML report.

read_attribute_value() None[source]

Read device attributes.

read_command_value(run_commands: list, run_commands_name: list) None[source]

Read device commands.

Parameters:
  • run_commands – commands safe to run without parameters

  • run_commands_name – commands safe to run with device name as parameter

read_config_all() None[source]

Read attribute and command configuration.

read_property_value() None[source]

Read device properties.

write_attribute_value(attrib: str, value: str) int[source]

Set value of attribute.

Parameters:
  • attrib – attribute name

  • value – attribute value

Returns:

error condition

class ska_tangoctl.tango_control.TangoctlDeviceBasic(logger: Logger, device: str, reverse: bool, list_items: dict = {}, timeout_millis: float = 500)[source]

Compile a basic dictionary for a Tango device.

__del__() None[source]

Destructor.

__init__(logger: Logger, device: str, reverse: bool, list_items: dict = {}, timeout_millis: float = 500)[source]

Iniltialise the thing.

Parameters:
  • logger – logging handle

  • device – device name

  • reverse – sort in reverse order

  • list_items – dictionary with values to process

  • timeout_millis – timeout in milliseconds

Raises:

Exception – error condition

__weakref__

list of weak references to the object (if defined)

make_json() dict[source]

Build dictionary.

Returns:

dictionary with device data

print_html() None[source]

Print data.

print_list(eol: str = '\n') None[source]

Print data.

Parameters:

eol – printed at the end

read_config() None[source]

Read additional data as configured in JSON file.

State, adminMode and versionId are specific to devices

class ska_tangoctl.tango_control.TangoctlDeviceConfig(logger: Logger, quiet_mode: bool, reverse: bool, device: str)[source]

Read all the configuration on offer.

__init__(logger: Logger, quiet_mode: bool, reverse: bool, device: str)[source]

Get it on.

Parameters:
  • logger – logging handle

  • quiet_mode – do not display progress bar

  • reverse – sort in reverse order

  • device – device name

get_json(delimiter: str = ',') dict[source]

Convert internal values to JSON.

Parameters:

delimiter – field are seperated by this

Returns:

dictionary

class ska_tangoctl.tango_control.TangoctlDevices(logger: Logger, uniq_cls: bool, quiet_mode: bool, reverse: bool, evrythng: bool, cfg_data: dict, tgo_name: str | None, tgo_attrib: str | None, tgo_cmd: str | None, tgo_prop: str | None, output_file: str | None, fmt: str = 'json', nodb: bool = False)[source]

Compile a dictionary of available Tango devices.

__del__() None[source]

Desctructor.

__init__(logger: Logger, uniq_cls: bool, quiet_mode: bool, reverse: bool, evrythng: bool, cfg_data: dict, tgo_name: str | None, tgo_attrib: str | None, tgo_cmd: str | None, tgo_prop: str | None, output_file: str | None, fmt: str = 'json', nodb: bool = False)[source]

Get a dict of devices.

Parameters:
  • logger – logging handle

  • uniq_cls – only read one device per class

  • cfg_data – configuration data in JSON format

  • quiet_mode – flag for displaying progress bars

  • reverse – sort in reverse order

  • evrythng – get commands and attributes regadrless of state

  • tgo_name – filter device name

  • tgo_attrib – filter attribute name

  • tgo_cmd – filter command name

  • tgo_prop – filter property name

  • output_file – output file name

  • fmt – output format

  • nodb – flag to run without database

Raises:

Exception – when database connect fails

make_json() dict[source]

Read device data.

Returns:

dictionary

print_html(disp_action: int) None[source]

Print in HTML format.

Parameters:

disp_action – display control flag

print_json(disp_action: int) None[source]

Print in JSON format.

Parameters:

disp_action – display control flag

print_markdown(disp_action: int) None[source]

Print in JSON format.

Parameters:

disp_action – display control flag

print_txt(disp_action: int, heading: str | None = None) None[source]

Print in text format.

Parameters:
  • disp_action – display control flag

  • heading – to be printed on the top

print_txt_list(heading: str | None = None) None[source]

Print list of devices.

Parameters:

heading – print at the top

print_txt_list_attrib() None[source]

Print list of devices with attribute name.

print_txt_list_attributes() None[source]

Print list of devices.

print_txt_list_commands() None[source]

Print list of devices.

print_txt_list_properties() None[source]

Print list of properties.

print_yaml(disp_action: int) None[source]

Print in YAML format.

Parameters:

disp_action – display control flag

read_attribute_values() None[source]

Read device data.

read_command_values() None[source]

Read device data.

read_device_values() None[source]

Read device data.

read_property_values() None[source]

Read device data.

class ska_tangoctl.tango_control.TangoctlDevicesBasic(logger: Logger, uniq_cls: bool, quiet_mode: bool, reverse: bool, evrythng: bool, cfg_data: Any, tgo_name: str | None, fmt: str, ns_name: str | None = None)[source]

Compile a dictionary of available Tango devices.

__del__() None[source]

Destructor.

__init__(logger: Logger, uniq_cls: bool, quiet_mode: bool, reverse: bool, evrythng: bool, cfg_data: Any, tgo_name: str | None, fmt: str, ns_name: str | None = None)[source]

Read list of Tango devices.

Parameters:
  • logger – logging handle

  • uniq_cls – only read one device per class

  • quiet_mode – flag for displaying progress bar

  • reverse – sort in reverse order

  • evrythng – read and display the whole thing

  • cfg_data – configuration data

  • fmt – output format

  • tgo_name – device name

  • ns_name – K8S namespace

Raises:

Exception – database connect failed

__weakref__

list of weak references to the object (if defined)

get_classes(reverse: bool) OrderedDict[Any, Any][source]

Get list of classes.

Parameters:

reverse – sort in reverse order

Returns:

dictionary of classes

make_json() dict[source]

Make dictionary of devices.

Returns:

dictionary with device data

print_html(disp_action: int) None[source]

Print in HTML format.

Parameters:

disp_action – display control flag

print_html_heading() None[source]

Print heading for list of devices.

print_json(disp_action: int) None[source]

Print in JSON format.

Parameters:

disp_action – not used

print_txt_classes() None[source]

Print list of classes.

print_txt_heading(eol: str = '\n') int[source]

Print heading for list of devices.

Parameters:

eol – printed at the end

Returns:

width of characters printed

print_txt_list(heading: str | None = None) None[source]

Print list of devices.

Parameters:

heading – print at the top

print_yaml(disp_action: int) None[source]

Print in YAML format.

Parameters:

disp_action – not used

read_configs() None[source]

Read additional data.

class ska_tangoctl.tango_control.TestTangoDevice(logger: Logger, device_name: str)[source]

Test a Tango device.

__init__(logger: Logger, device_name: str)[source]

Get going.

Parameters:
  • logger – logging handle

  • device_name – Tango device name

__weakref__

list of weak references to the object (if defined)

admin_mode_off() None[source]

Turn admin mode off.

admin_mode_on() None[source]

Turn admin mode on.

check_device() bool[source]

Check that device is online.

Returns:

online condition

device_off() int[source]

Turn this device off.

Returns:

error condition

device_on() int[source]

Turn this device on.

Returns:

error condition

device_standby() int[source]

Set this device to standby mode.

Returns:

error condition

device_status() int | None[source]

Print device status.

Returns:

device state

get_admin_mode() int | None[source]

Read attribute for admin mode.

Returns:

attribute value

get_simulation_mode() int | None[source]

Read attribute for simulation mode.

Returns:

attribute value

read_device_attributes() None[source]

Read all attributes of this device.

run_test(dry_run: bool, dev_admin: int | None, dev_off: bool, dev_on: bool, dev_sim: int | None, dev_standby: bool, dev_status: bool, show_command: bool, show_attrib: bool, tgo_attrib: str | None, tgo_name: str | None, tango_port: int) int[source]

Run tests on Tango devices.

Parameters:
  • dry_run – only show what will be done

  • dev_admin – check admin mode

  • dev_off – turn device on

  • dev_on – turn device off

  • dev_sim – simulation flag

  • dev_standby – place device in standby

  • dev_status – set device status

  • show_command – test device commands

  • show_attrib – test device attributes

  • tgo_attrib – name of attribute

  • tgo_name – device name

  • tango_port – device port

Returns:

error condition

set_admin_mode(admin_mode: int) int[source]

Change admin mode.

Parameters:

admin_mode – new value

Returns:

error condition

set_simulation_mode(dev_sim: int | None) int | None[source]

Set attribute for simulation mode.

Parameters:

dev_sim – attribute value

Returns:

error condition

show_device_attributes(show: bool = False) None[source]

Display number and names of attributes.

Parameters:

show – flag to print names

show_device_commands(show: bool = False) None[source]

Display number and names of commands.

Parameters:

show – flag to print names

test_admin_mode(dev_admin: int) int[source]

Test admin mode.

Parameters:

dev_admin – new value

Returns:

error condition

test_all(show_attrib: bool) int[source]

Test everything that device can do.

Parameters:

show_attrib – flag for attributes display.

Returns:

error condition

test_off(dev_sim: int | None) int[source]

Test that device can be turned off.

Parameters:

dev_sim – flag for hardware simulation.

Returns:

error condition

test_on(dev_sim: int | None) int[source]

Test that device can be turned on.

Parameters:

dev_sim – flag for hardware simulation.

Returns:

error condition

test_simulation_mode(dev_sim: int | None) int[source]

Test that device hardware simulation can be set.

Parameters:

dev_sim – flag for hardware simulation.

Returns:

error condition

test_standby(dev_sim: int | None) int[source]

Test that device can be placed into standby mode.

Parameters:

dev_sim – flag for hardware simulation.

Returns:

error condition

test_status() int[source]

Test that device status can be read.

Returns:

error condition

test_subscribe(attrib: str) int[source]

Test subscribed to event.

Parameters:

attrib – attribute name

Returns:

error condition

ska_tangoctl.tango_control.check_tango(tango_fqdn: str, tango_port: int = 10000) int[source]

Check Tango host address.

Parameters:
  • tango_fqdn – fully qualified domain name

  • tango_port – port number

Returns:

error condition

ska_tangoctl.tango_control.show_obs_state(obs_stat: int) None[source]

Display Python enumerated type for observing state.

Parameters:

obs_stat – observing state numeric value