mxcubecore.CommandContainer#

CommandContainer module

Classes: - CommandContainer, a special mixin class to be used with Hardware Objects. It defines a container for command launchers and channels (see Command package). - C*Object, command launcher & channel base class

Classes

ChannelObject(name[, username])

CommandContainer()

Mixin class for generic command and channel containers

CommandObject(name[, username])

Exceptions

ConnectionError

General Connection Error

class mxcubecore.CommandContainer.CommandContainer[source]#

Bases: object

Mixin class for generic command and channel containers

add_channel(attributes_dict: Dict[str, Any], channel: str, add_now: bool = True) ChannelObject | None[source]#

Add channel.

Parameters:
  • attributes_dict (Dict[str, Any]) – Channel attributes.

  • channel (str) – Channel name.

  • add_now (bool, optional) – Whether the channel should be added now.

  • True. (Defaults to) –

Raises:

ConnectionError – If a connection error occured while adding the channel.

Returns:

Channel object or None if adding later.

Return type:

Union[ChannelObject, None]

add_command(arg1: Dict[str, Any], arg2: str | None = None, add_now: bool = True) CommandObject | None[source]#

Add command.

Parameters:
  • arg1 (Dict[str, Any]) – Command attributes.

  • arg2 (Optional[str], optional) – Command name. Defaults to None.

  • add_now (bool, optional) – Whether to add command now. Defaults to True.

Raises:

ConnectionError – If a connection error occured while adding the command.

Returns:

Command object or None if adding later.

Return type:

Union[CommandObject, None]

execute_command(command_name: str, *args, **kwargs) Any[source]#

Execute command.

Parameters:
  • command_name (str) – Command name.

  • *args (tuple) – Arguments to pass through to the command to be executed.

  • **kwargs (Dict[str, Any]) – Named arguments to pass through to the

  • executed. (command to be) –

Raises:

AttributeError – If command not found.

Returns:

Execution output.

Return type:

Any

get_channel_names_list() List[str][source]#

Get a list of all channel names.

Returns:

Channel names.

Return type:

List[str]

get_channel_object(channel_name: str, optional: bool = False) ChannelObject | None[source]#

Get channel.

Parameters:
  • channel_name (str) – Channel name.

  • optional (bool, optional) – If a missing channel should be logged

  • False. (as an error. Defaults to) –

Returns:

Channel object or None if not found.

Return type:

Union[ChannelObject, None]

get_channel_value(channel_name: str) Any[source]#

Get channel value.

Parameters:

channel_name (str) – Channel name.

Returns:

Channel value.

Return type:

Any

get_channels() Generator[ChannelObject, None, None][source]#

Get object channels.

Yields:

Generator[ChannelObject, None, None] – Object channels.

Return type:

Generator[ChannelObject, None, None]

get_command_names_list() List[str][source]#

Get list of command names.

Returns:

Command names.

Return type:

List[str]

get_command_object(cmd_name: str) CommandObject | None[source]#

Get command object.

Parameters:

cmd_name (str) – Command name.

Returns:

Command object or None if not found.

Return type:

Union[CommandObject, None]

get_commands() Generator[CommandObject, None, None][source]#

Get object commands.

Yields:

Generator[CommandObject, None, None] – Command objects.

Return type:

Generator[CommandObject, None, None]

set_channel_value(channel_name: str, value: Any) None[source]#

Set channel value.

Parameters:
  • channel_name (str) – Channel name.

  • value (Any) – Value to set.

Return type:

None

exception mxcubecore.CommandContainer.ConnectionError[source]#

Bases: Exception

General Connection Error