qcodes.utils.command

class qcodes.utils.command.Command(arg_count, cmd=None, exec_str=None, input_parser=None, output_parser=None, no_cmd_function=None)[source]

Bases: object

Create a callable command from a string or function.

Parameters
  • arg_count (int) – The number of arguments to the command.

  • cmd (Optional[Union[str, Callable]]) – If a function, it will be called directly when the command is invoked. If a string, it should contain positional fields to .format like '{}' or '{0}', and it will be passed on to exec_str after formatting.

  • exec_str (Optional[Callable]) – If provided, should be a callable taking one parameter, the cmd string after parameters are inserted. If not provided, cmd must not be a string.

  • input_parser (Optional[Callable]) – Transform the input arg(s) before sending them to the command. If there are multiple arguments, this function should accept all the arguments in order, and return a tuple of values.

  • output_parser (Optional[Callable]) – Transform the return value of the command.

  • no_cmd_function (Optional[Callable]) – If provided and we cannot create a command to return, we won’t throw an error on constructing the command. Instead, we call this function when the command is invoked, and it should probably throw an error of its own (eg NotImplementedError).

Raises
  • TypeError – If no_cmd_function is not the expected type.

  • TypeError – If input_parser is not the expected type.

  • TypeError – If output_parser is not the expected type.

  • TypeError – If exec_string is not the expected type.

  • NoCommandError – If no cmd is found no_cmd_function is missing.

call_by_str(*args)[source]

Execute a formatted string.

call_by_str_parsed_out(*args)[source]

Execute a formatted string with output parsing.

call_by_str_parsed_in(arg)[source]

Execute a formatted string with 1-arg input parsing.

call_by_str_parsed_in_out(arg)[source]

Execute a formatted string with 1-arg input and output parsing.

call_by_str_parsed_in2(*args)[source]

Execute a formatted string with multi-arg input parsing.

call_by_str_parsed_in2_out(*args)[source]

Execute a formatted string with multi-arg input & output parsing.

call_cmd_parsed_out(*args)[source]

Execute a function with output parsing.

call_cmd_parsed_in(arg)[source]

Execute a function with 1-arg input parsing.

call_cmd_parsed_in_out(arg)[source]

Execute a function with 1-arg input and output parsing.

call_cmd_parsed_in2(*args)[source]

Execute a function with multi-arg input parsing.

call_cmd_parsed_in2_out(*args)[source]

Execute a function with multi-arg input & output parsing.

__call__(*args)[source]

Invoke the command.

exception qcodes.utils.command.NoCommandError[source]

Bases: Exception

args
with_traceback()

Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.