RTC Toolkit 6.0.0
Loading...
Searching...
No Matches
cli.operations.Operations Class Reference

This class provided methods that implement the various sub-command operations of the command line interface. More...

Public Member Functions

 __init__ (self, ConfigurationManager config_manager)
 Initialise an Operations object with the configTool's configuration manager.
 
 reload_config (self)
 Refreshes the configuration managed by the configuration manager and updates the internal cached configuration.
 
 get_repository (self, str repo)
 Return the appropriate repository adapter based on the value of the repo option string.
 
 run_shell (self, str repo_name)
 Setup the repository object and enter a Python shell for interactive mode.
 
 list_datapoints (self, str repo_name, path, bool recursive)
 List all available datapoints and sub-paths found under a given path.
 
 get_datapoint (self, str repo_name, DataPointPath path, bool get_type, bool get_size, bool use_repr)
 Get and print the datapoint value to console.
 
 set_datapoint (self, str repo_name, DataPointPath path, str value, Optional[Any] requested_type=None)
 Set a datapoint's value.
 
 read_hierarchy (self, DataPointPath path, str output_path, Optional[str] repo_name=None, Optional[RepositoryIf] repo=None)
 Reads a datapoint or hierarchy from the repository and stores the data in local files.
 
 write_hierarchy (self, DataPointPath path, str input_path, Optional[str] repo_name=None, Optional[RepositoryIf] repo=None)
 Loads data from local files and writes them into the repository.
 
 delete_datapoints (self, str repo_name, DataPointPath path, bool recursive)
 Deletes a single datapoint or a whole hierarchy if recursive is set to True.
 
 populate_runtime_repository (self)
 Populate the Runtime Configuration Repository.
 
 validate_persistent_repository (self)
 Validate the structure and contents of the Persistent Configuration Repository.
 

Static Public Member Functions

 parse_value (str value, Optional[Any] requested_type=None)
 Parses a string value as a Python literal expression.
 

Public Attributes

 config_manager = config_manager
 

Protected Member Functions

 _log_repository_name (self, str repo)
 log the repository endpoint.
 
 _yaml_read_iterator (self, str input_file)
 A generator that iterates recursively over a YAML input file, returning (path, type, data) for each datapoint found in the file.
 
 _repo_iterator (self, RepositoryIf repo, DataPointPath path)
 A generator function to iterate recursively over an input repository datapoint path.
 
 _set_datapoint_force (self, RepositoryIf repo, DataPointPath path, data_type, data)
 Helper function used to set a datapoint in the repository.
 

Protected Attributes

 _config = self.config_manager.get_active_config_as_dataclass()
 
 _logger = CiiLogManager.get_logger()
 

Detailed Description

This class provided methods that implement the various sub-command operations of the command line interface.

Constructor & Destructor Documentation

◆ __init__()

cli.operations.Operations.__init__ ( self,
ConfigurationManager config_manager )

Initialise an Operations object with the configTool's configuration manager.

Parameters
config_managerShould be an instance of the tool's configuration manager.

Member Function Documentation

◆ _log_repository_name()

cli.operations.Operations._log_repository_name ( self,
str repo )
protected

log the repository endpoint.

◆ _repo_iterator()

cli.operations.Operations._repo_iterator ( self,
RepositoryIf repo,
DataPointPath path )
protected

A generator function to iterate recursively over an input repository datapoint path.

Yields (path, type, data) for each datapoint, where the path is the full path for the datapoint within the repository, type is the type of the datapoint as known by RepositoryIf, and data is the value of the datapoint.

◆ _set_datapoint_force()

cli.operations.Operations._set_datapoint_force ( self,
RepositoryIf repo,
DataPointPath path,
data_type,
data )
protected

Helper function used to set a datapoint in the repository.

The datapoint is created if it does not exist. If it exists with the wrong data type, it is deleted and recreated with the correct one. Otherwise, its value is simply updated.

◆ _yaml_read_iterator()

cli.operations.Operations._yaml_read_iterator ( self,
str input_file )
protected

A generator that iterates recursively over a YAML input file, returning (path, type, data) for each datapoint found in the file.

◆ delete_datapoints()

cli.operations.Operations.delete_datapoints ( self,
str repo_name,
DataPointPath path,
bool recursive )

Deletes a single datapoint or a whole hierarchy if recursive is set to True.

Parameters
repo_nameMust be "runtime" or "persistent", indicating the type of the repository.
pathThe path of the datapoint or hierarchy to delete.
recursiveIf True then all datapoints found under path are deleted recursively.

◆ get_datapoint()

cli.operations.Operations.get_datapoint ( self,
str repo_name,
DataPointPath path,
bool get_type,
bool get_size,
bool use_repr )

Get and print the datapoint value to console.

If the get_type flag is used then the datapoint type is printed in the same format as is accepted by the –type argument. If the use_repr flag is True then the value of the datapoint is printed using Python 'repr', which should produce a string representation that is compatible with Python literal syntax.

Parameters
repo_nameMust be "runtime" or "persistent", indicating the type of the repository.
pathThe path of the datapoint to read.
get_typeIf True then the datapoint type is printed instead.
get_sizeIf True then the size of the datapoint is printed instead.
use_reprIndicates if output should be compatible with Python literal syntax.

◆ get_repository()

cli.operations.Operations.get_repository ( self,
str repo )

Return the appropriate repository adapter based on the value of the repo option string.

Parameters
repoMust be "runtime" or "persistent", indicating the repository type to return.
Returns
An instance of RuntimeRepoIf or PersistentRepoIf depending on the value of repo.

◆ list_datapoints()

cli.operations.Operations.list_datapoints ( self,
str repo_name,
path,
bool recursive )

List all available datapoints and sub-paths found under a given path.

Parameters
repo_nameMust be "runtime" or "persistent", indicating the type of the repository.
pathThe path to the datapoint hierarchy to list.
recursiveIf True then we print all datapoints found under path recursively.

◆ parse_value()

cli.operations.Operations.parse_value ( str value,
Optional[Any] requested_type = None )
static

Parses a string value as a Python literal expression.

This will parse and return the given value and optionally try to convert to the requested RTC Toolkit type if given. requested_type should be one of the type classes from rtctk.framework or None. If None is used then the type is deduced from the value. In case it is not possible to deduce the type a BadParameter exception is thrown.

Parameters
valueThe input string with a Python literal to parse.
requested_typeOptional type that the return value should be converted to.
Returns
The parsed data object.

◆ populate_runtime_repository()

cli.operations.Operations.populate_runtime_repository ( self)

Populate the Runtime Configuration Repository.

This will copy the data from the Persistent Configuration Repository into the Runtime Configuration Repository using the same logic as RTC Supervisor.

◆ read_hierarchy()

cli.operations.Operations.read_hierarchy ( self,
DataPointPath path,
str output_path,
Optional[str] repo_name = None,
Optional[RepositoryIf] repo = None )

Reads a datapoint or hierarchy from the repository and stores the data in local files.

The datapoint or hierarchy of datapoints indicated by path are copied from the repository and written to the file or directory indicated by output_path. The output format used depends on the file extension used or if a directory has been given instead. The following output formats are supported:

  • FITS - if output_path ends in '.fits'.
  • YAML - if output_path ends in '.yaml'.
  • Directory layout compatible with PersistentRepoAdapter - if a directory is given.

The repository to access must be identified by either providing 'repo_name' or the adapter object directly with 'repo'.

Parameters
pathThe path of the datapoint or hierarchy to read from.
output_pathThe path of the output file or directory.
repo_nameName of the repository 'runtime' or 'persistent'.
repoThe repository adapter.

◆ reload_config()

cli.operations.Operations.reload_config ( self)

Refreshes the configuration managed by the configuration manager and updates the internal cached configuration.

◆ run_shell()

cli.operations.Operations.run_shell ( self,
str repo_name )

Setup the repository object and enter a Python shell for interactive mode.

Parameters
repo_nameMust be "runtime" or "persistent", indicating the type of the repository.

◆ set_datapoint()

cli.operations.Operations.set_datapoint ( self,
str repo_name,
DataPointPath path,
str value,
Optional[Any] requested_type = None )

Set a datapoint's value.

If the datapoint does not exist it is created with the type indicated by requested_type. If the datapoint already exists and requested_type is not None then it is first cross checked with the datapoint's actual type.

Parameters
repo_nameMust be "runtime" or "persistent", indicating the type of the repository.
pathThe path of the datapoint to set or create.
valueThe value to set for the datapoint as a Python literal string.
requested_typeThe data type of the new datapoint.

◆ validate_persistent_repository()

cli.operations.Operations.validate_persistent_repository ( self)

Validate the structure and contents of the Persistent Configuration Repository.

◆ write_hierarchy()

cli.operations.Operations.write_hierarchy ( self,
DataPointPath path,
str input_path,
Optional[str] repo_name = None,
Optional[RepositoryIf] repo = None )

Loads data from local files and writes them into the repository.

Data is read from the file or directory indicated by input_path and written to the corresponding datapoints into the repository under the given datapoint path hierarchy. The expected format of the input files depends on the file extension of input_path, or if it points to a directory. The following input formats are supported:

  • FITS - if input_path ends in '.fits'.
  • YAML - if input_path ends in '.yaml'.
  • Directory layout compatible with PersistentRepoAdapter - if a directory is given.

The repository to access must be identified by either providing 'repo_name' or the adapter object directly with 'repo'.

Parameters
pathThe path of the datapoint or hierarchy to write to.
input_pathThe path of the input file or directory.
repo_nameName of the repository 'runtime' or 'persistent'.
repoThe repository adapter.

Member Data Documentation

◆ _config

cli.operations.Operations._config = self.config_manager.get_active_config_as_dataclass()
protected

◆ _logger

cli.operations.Operations._logger = CiiLogManager.get_logger()
protected

◆ config_manager

cli.operations.Operations.config_manager = config_manager

The documentation for this class was generated from the following file: