pcvs.io module

class pcvs.io.PCVSConsole(color=True, verbose=0)[source]

Bases: object

Main 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.

create_table(title, cols)[source]

Create and return a rich table.

Return type:

Table

crit_debug(fmt)[source]

Print & log debug for pcvs criterions.

Return type:

None

critical(fmt)[source]

Print a log critical error then exit.

Return type:

None

debug(fmt)[source]

Print debug.

Return type:

None

error(fmt)[source]

Print an error messages.

Return type:

None

exception(e)[source]

Print exceptions.

Return type:

None

info(fmt)[source]

Print info.

Return type:

None

log(fmt)[source]

Print log.

Return type:

None

property logfile: str

Get the path to the logging file.

Returns:

the logging file

property logger: Logger

Get Logger.

move_debug_file(newdir)[source]
Return type:

None

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(fmt='')[source]

Print a line to stdout.

Return type:

None

print_banner()[source]

Print the PCVS logo fitting with current terminal size

Return type:

None

print_box(txt, panel_options)[source]

Print a Box.

Return type:

None

print_header(txt)[source]

Print Header.

Return type:

None

print_item(txt, depth=1)[source]

Print Item.

Return type:

None

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 information

  • state (TestState) – The status of the printed test

  • tlabel (str) – The label of the test.

  • tsubtree (str) – Thr sub directory of the test

  • content (str | None) – stdout/stderr of the test, if specify

Return type:

None

print_job_summary()[source]

Print the job view table once.

Return type:

None

print_rich(to_print)[source]

Print rich formatted object.

Return type:

None

print_section(txt)[source]

Print Section.

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)

sched_debug(fmt)[source]

Print & log debug for pcvs scheduler.

Return type:

None

setoutfile(file)[source]
Return type:

None

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.

warn(fmt)[source]

Short for warning.

Return type:

None

warning(fmt)[source]

Print warning.

Return type:

None

class pcvs.io.SpecialChar(utf_support=True)[source]

Bases: object

Class 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: IntEnum

Enum 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 caught

  • user_func (Optional[Callable[[Exception], None]]) – Optional, a function to call to manage the exception

  • doexit (bool) – Optional, should pcvs exit after printing the error

Return type:

Callable[[Callable], Callable[[Any], Any]]

Returns:

function handler to manage exception

pcvs.io.detach_console()[source]

Detach the PCVS Console.

Return type:

None

pcvs.io.init(color=True, verbose=0)[source]

Init the PCVS Console.

Return type:

None