TestScript#

class lsst.ts.salobj.TestScript(index, descr='test script')#

Bases: BaseScript

Test script to allow testing BaseScript.

Parameters:
  • index (int) – Index of Script SAL component.

  • descr (str, optional) – Brief description. Note: this is not a typical constructor argument for scripts. It is present in case subclasses or unit tests wish to override the default.

  • time (Wait for the specified)

  • details. (then exit. See configure for)

Methods Summary

cleanup()

Perform final cleanup, if any.

configure(config)

Configure the script.

get_schema()

Return a jsonschema to validate configuration, as a dict.

run()

Run the script.

set_metadata(metadata)

Set metadata fields in the provided struct, given the current configuration.

Methods Documentation

async cleanup()#

Perform final cleanup, if any.

This method is called as the script state is exiting, unless the script had not yet started to run, or the script process is aborted by SIGTERM or SIGKILL.

Return type:

None

async configure(config)#

Configure the script.

Parameters:

config (types.SimpleNamespace) – Configuration, as described by schema.

Raises:

salobj.ExpectedError – If wait_time < 0. This can be used to make config fail.

Return type:

None

classmethod get_schema()#

Return a jsonschema to validate configuration, as a dict.

Please provide default values for all fields for which defaults make sense. This makes the script easier to use.

If your script has no configuration then return None, in which case the config field of the configure command must be an empty string.

Return type:

dict[str, str]

async run()#

Run the script.

Your subclass must provide an implementation, as follows: :rtype: None

  • At points where you support pausing call checkpoint.

  • Raise an exception on error. Raise base.ExpectedError to avoid logging a traceback.

Notes

This method is only called when the script state is ScriptState.CONFIGURED. The remaining state transitions are handled automatically.

set_metadata(metadata)#

Set metadata fields in the provided struct, given the current configuration.

Parameters:

metadata (self.evt_metadata.DataType()) – Metadata to update. Set those fields for which you have useful information.

Return type:

None

Notes

This method is called after configure by do_configure. The script state will be ScriptState.UNCONFIGURED.