Global -> Logger Handlers
TARDIS log
- tardis_em.utils.logo.print_progress_bar(value: int, max_v: int)
Code by Robert Kiewisz
Displays a progress bar indicating the percentage of completion. The progress bar is dynamically adjusted based on the terminal’s width in interactive mode. In non-interactive environments or in case of error, a default width is used.
- Parameters:
value – The current progress value. Must be a non-negative integer less than or equal to max_v.
max_v – The maximum value for the progress bar, representing 100% progress. Must be a positive integer greater than 0.
- Returns:
A formatted string representation of a progress bar including the current percentage of completion and value status.
- Return type:
str
- tardis_em.utils.logo.is_interactive()
Code by Robert Kiewisz
Simple check if a command line window is from Jupiter.
- class tardis_em.utils.logo.TardisLogo(logo=True)
Class for managing TARDIS logo display and formatting within a console or Jupyter environment.
- static clear_output(wait=True)
Clears the current output displayed in the terminal or within an interactive environment.
- Parameters:
wait (bool) – Determines whether the clearing of the output should wait for the display to be updated. The functionality of this parameter applies specifically when an interactive shell is being used.
- cell_width()
Adjusts the cell width based on the environment and terminal properties.
- tardis_em.utils.logo.print_error(message: str, title: str = 'ERROR') None
Code by Robert Kiewisz
Print a (multi-line) error message inside the TARDIS logo box.
Reuses
TardisLogo(without the robot art, so the body spans the full box width) to give errors the same branded frame as the startup banner. The first 12 lines fill the box; any overflow is printed plainly beneath it. The renderer truncates lines longer than the box width, so keep each line short.- Parameters:
message – the error text (newline-separated lines).
title – short title shown in the box header.
- class tardis_em.utils.logo.ContextFilter(name='')
Code by Robert Kiewisz Logging filter to add hostname information to log records.
- hostname = 'runnervm8k3b6'
- filter(record)
Determine if the specified record is to be logged.
Returns True if the record should be logged, or False otherwise. If deemed appropriate, the record may be modified in-place.
TARDIS errors
- tardis_em.utils.errors.standard_error_id(id_s: str)
Fetches the standard error message corresponding to the provided ID.
This function attempts to look up an error ID in a predefined dictionary and returns the associated error message. If the ID does not exist in the dictionary, it falls back to a default string indicating an unknown error.
- Parameters:
id_s (str) – The identifier string for the error to search in the dictionary.
- Returns:
Corresponding error message if the ID is found, else “UNKNOWN_ERROR”.
- Return type:
str
- exception tardis_em.utils.errors.TardisError(id_='0', py='NA', desc='Unknown exertion occurred!', warning_b=True)
Handles errors specific to the TARDIS framework and provides mechanisms for standardized error logging, message formatting, and interactive displays.
The class allows the creation of custom error messages with standardized identifiers, logs error-related information to a file, and supports formatted, error-specific console notifications. It also facilitates the truncation of long error descriptions to fit within terminal display constraints.
- cut_desc(desc: str) Tuple[str, str, str, str, str, str, str, str]
Splits the given string desc into multiple smaller strings, ensuring each split string does not exceed the defined width. The method first retrieves the available width for truncation and then decides whether the input string needs splitting. If the string is shorter than or equal to the width, no splitting is done; otherwise, the string is truncated into multiple parts using the _truncate_str method.
- Parameters:
desc (str) – The input string to be truncated and split into smaller parts.
- Returns:
A tuple containing up to eight parts of the truncated string. Parts that are not used remain as empty strings.
- Return type:
Tuple[str, str, str, str, str, str, str, str]