The interpreter communication channels

command_interpreter.signals – Signals

CommandInterpreter uses PyQt like signals to communicate with the external word.

The names of the emit methods arguments are the type of the parameter followed by an underscore and optionally by an explanatory name.

Available signals are:

  • command_string: accept an int and a string;

    CICommandString.emit(int_, string_)[source]
    Parameters:
    int_ : int

    loop number

    string_ : string

    string of the command

  • progress: accept four numbers, the total expected number, the number of done, of skipped and of failures;

    CIProgress.emit(int_tot, int_done, int_skipped, int_fail)[source]
    Parameters:
    int_tot : int

    total number of jobs

    int_done : int

    number of finished jobs; the number of successful jobs is int_done - int_skipped - int_fail

    int_skipped : int

    number of skipped jobs

    int_fail : int

    number of failed jobs

  • command_done: accept a boolean: True for the end of the command interpreter, False for the end of one single command;

    CICommandDone.emit(bool_global)[source]
    Parameters:
    bool_global : boolean

    if True, the command interpreter is done, if False a single command is done

  • global_logger: accept an integer and a string

    CIGlobalLogger.emit(int_level, string_msg)[source]
    Parameters:
    int_level : integer

    logging level; see the logging documentation for more information

    string_msg : string

    string to log

  • n_primaries: accept an integer

    CINPrimaries.emit(int_)[source]
    Parameters:
    int_ : integer

    number of primary files

  • commands: accept six strings and a dictionary. The first string is the primary value; the second the command with all the substitutions in place, if the execution finished, or with the placeholder, if some exception has been raised; the third and fourth are the stdout and stderr of the executed command; the fifth is non empty if the command has a non-null return code; the sixth is non empty is the execution of the command crashes for some reason; the seventh is the configuration dictionary passed to the CommandInterpreter

    CINPrimaries.emit(int_)[source]
    Parameters:
    int_ : integer

    number of primary files

vdat.command_interpreter.signals.register(name)[source]

Initialise the decorated class and save it into the signals dictionary with name as key

Parameters:
name : string

name under which the class or instance must be registered

Returns:
decorator : function

class decorator

class vdat.command_interpreter.signals.BaseCISignal[source]

Bases: object

Base implementation for the signals used in the CommandInterpreter

Attributes:
connected : list

list of the connected callables

connected

list of the connected callables

connect(callable_)[source]

Connect the callable with the signal

Parameters:
callable_ :

function/method/callable instance to connect with the signal

disconnect(callable_)[source]

Remove the first instance of callable from the signal

Parameters:
callable_ :

function/method/callable instance to disconnect from the signal

Raises:
ValueError

if the callable is not already connected

clear()[source]

Remove all the associated signals

emit(*args, **kwargs)[source]

Abstract method that emit the signal, executing all the registered callables.

The default implementation loop through the connected and call them. Reimplement to give it a proper signature.

class vdat.command_interpreter.signals.CICommandString[source]

Bases: vdat.command_interpreter.signals.BaseCISignal

Emit the string of the command to execute after substituting the keywords

emit(int_, string_)[source]
Parameters:
int_ : int

loop number

string_ : string

string of the command

class vdat.command_interpreter.signals.CIProgress[source]

Bases: vdat.command_interpreter.signals.BaseCISignal

Emit informations about execution progress

emit(int_tot, int_done, int_skipped, int_fail)[source]
Parameters:
int_tot : int

total number of jobs

int_done : int

number of finished jobs; the number of successful jobs is int_done - int_skipped - int_fail

int_skipped : int

number of skipped jobs

int_fail : int

number of failed jobs

class vdat.command_interpreter.signals.CICommandDone[source]

Bases: vdat.command_interpreter.signals.BaseCISignal

Signal emitted when a command has been executed or the run of the interpreter is done

emit(bool_global)[source]
Parameters:
bool_global : boolean

if True, the command interpreter is done, if False a single command is done

class vdat.command_interpreter.signals.CIGlobalLogger[source]

Bases: vdat.command_interpreter.signals.BaseCISignal

Log information about the command interpreter execution. This channel is not used to log the execution of the commands.

emit(int_level, string_msg)[source]
Parameters:
int_level : integer

logging level; see the logging documentation for more information

string_msg : string

string to log

class vdat.command_interpreter.signals.CINPrimaries[source]

Bases: vdat.command_interpreter.signals.BaseCISignal

Emit the number of primary files collected

emit(int_)[source]
Parameters:
int_ : integer

number of primary files

class vdat.command_interpreter.signals.CICommandLogger[source]

Bases: vdat.command_interpreter.signals.BaseCISignal

For each primary emits the primary name(s), the actual command string executed in the subprocess, the log messages and the full configuration dictionary.

emit(string_primary, string_command, string_info, string_warning, string_error, string_critical, dict_config)[source]
Parameters:
int_ : integer

number of primary files

vdat.command_interpreter.signals.get_signal(name)[source]

Get the signal associated with name

Parameters:
name : string

name of the requested relay

Returns:
one of the registered signal instances
vdat.command_interpreter.signals.get_signal_names()[source]

Get the full list of signals

command_interpreter.helpers – Helper functionalities

Helper function and classes.

These functionalities are not essential for the interpreter, but can help the to setup things.

vdat.command_interpreter.helpers.print_first(int_, string_)[source]

Print string_ when int_ is zero.

Can be connected to vdat.command_interpreter.signals.CICommandString

vdat.command_interpreter.helpers.print_progress(int_tot, int_done, int_skipped, int_fail)[source]

Print the percentages of finished, successful and failed jobs, overwriting the line. Skipped are counted as successful.

Can be connected to vdat.command_interpreter.signals.CIProgress

vdat.command_interpreter.helpers.print_done(bool_cidone)[source]

Function that prints command done when bool_cidone == False and execution done otherwise

Can be connected to vdat.command_interpreter.signals.CICommandDone

vdat.command_interpreter.helpers.print_global_logger(int_level, string_msg)[source]

Function that prints levelname: string_msg. The conversion is done

Can be connected to vdat.command_interpreter.signals.CIGlobalLogger

vdat.command_interpreter.helpers.print_n_primaries(int_)[source]

Function that prints Number of primaries: int_.

Can be connected to vdat.command_interpreter.signals.CINPrimaries

vdat.command_interpreter.helpers.log_command_logger(string_primary, string_command, string_info, string_warning, string_error, string_critical, dict_config)[source]

Function that log the command, and the strings_{info,warning,error,critical} to a logger called with the name of the executable, from the first element of the string command.

Can be connected to vdat.command_interpreter.signals.CICommandLogger