pcvs.io module
- class pcvs.io.PCVSConsole(color=True, verbose=0)[source]
Bases:
objectMain interface to print information to users.
Any output from the application should be handled by this Console.
Build a new Console: - color: boolean (color support) - verbose: boolean (verbose msg mode in log files) Any other argument is considered a base class options.
- Parameters:
color (
bool) – should the console use color.verbose (
int) – verbosity level of the console.
- property logfile: str
Get the path to the logging file.
- Returns:
the logging file
- property logger: Logger
Get Logger.
- nodebug(fmt)[source]
Do nothing, place holder to remove debug print without deleting lines.
- Return type:
None
- property outfile: str
Get the path where the Console output is logged (disabled by default).
- Returns:
the file path
- print_job(status, state, tlabel, tsubtree, content=None)[source]
Print a Job.
If Verbosity level is equal or above Verbosity.DETAILED, print each tests. Otherwise, print a summary block. Optionally print raw test result content.
- Parameters:
status (
str) – The status line indicating test informationstate (
TestState) – The status of the printed testtlabel (
str) – The label of the test.tsubtree (
str) – Thr sub directory of the testcontent (
str|None) – stdout/stderr of the test, if specify
- Return type:
None
- progress_iter(it)[source]
Print a progress bar using click.
- Parameters:
it (
Iterable) – iterable on which the progress bar has to iterate- Return type:
Iterable- Returns:
a click progress bar (iterable)
- table_container(total)[source]
The main pcvs run progress bar that may include job summary.
- Return type:
Live
- utf(k)[source]
Return the encoding supported by this session for the given key.
- Parameters:
k (
str) – the key as defined by SpecialChar- Return type:
str- Returns:
the associated printable sequence
- property verbosity: int
Return the Verbosity level.
- class pcvs.io.SpecialChar(utf_support=True)[source]
Bases:
objectClass mapping special char display.
Enabled or disabled according to utf support.
Initialize a new char handler depending on utf support
- Parameters:
utf_support (
Optional[bool]) – support for utf encoding, defaults to True
- copy = '©'
- fail = '✘'
- git = '⍿'
- hdr = '⎼'
- item = '⟢'
- none = '∅'
- sec = '❖'
- sep_h = '⎼'
- sep_v = ' ⍿ '
- star = '★'
- succ = '✔'
- time = '⌚'
- class pcvs.io.Verbosity(*values)[source]
Bases:
IntEnumEnum to map a verbosity level to a more convenient label.
COMPACT: compact way, jobs are displayed packed per input YAML file.
DETAILED: each job will output result on a one-line manner.
INFO: DETAILED & INFO messages will be logged.
LOG: DETAILED & INFO & LOG messages will be logged.
DEBUG: DETAIL, INFO, LOG & DEBUG messages, with more infos in stack traces.
- COMPACT = 0
- DEBUG = 4
- DETAILED = 1
- INFO = 2
- LOG = 3
- NB_LEVELS = 5
- pcvs.io.capture_exception(e_type, user_func=None, doexit=True)[source]
Wraps functions to capture unhandled exceptions for high-level function not to crash.
- Parameters:
e_type (
Any) – errors to be caughtuser_func (
Optional[Callable[[Exception],None]]) – Optional, a function to call to manage the exceptiondoexit (
bool) – Optional, should pcvs exit after printing the error
- Return type:
Callable[[Callable],Callable[[Any],Any]]- Returns:
function handler to manage exception