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, ifFalse
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 theCommandInterpreter
-
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 keyParameters: - 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
: listlist 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
-
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
-
class
vdat.command_interpreter.signals.
CIProgress
[source]¶ Bases:
vdat.command_interpreter.signals.BaseCISignal
Emit informations about execution progress
-
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
-
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
-
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.
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_
whenint_
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
whenbool_cidone == False
andexecution done
otherwiseCan 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 doneCan 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