Fork of nornir-rich to support placing each individual nornir result var into its own dedicated rich panel (which in turn prettifies dictionary keys/values)
Project description
nornir_rich_panelvar
This is a fork of nornir-rich, I have published it separately as am not sure if the original package is still maintained (issue20) and need a way to enable the installation of my forked changes as a PyPI dependency.
- The per_panel_var branch (of changes) has been retained incase the package maintainer ever agrees to a PR for the changes in this fork
- Github actions are disabled in this fork as they fail on the first python version (3.8) due to an issue with poetry install
Extra features added by this fork
The following extra options can be set in the print_result method, the defaults keep the original nornir-rich behaviour:
- print_empty_task (default True): If set to False will not print a task if the task result is Null or an empty string ("")
- per_panel_var (default False): If set to True puts each individual nornir result var into its own dedicated rich panel. If the var is a dictionary rather than having the var name (for example result) within the panel it prettifies it to instead use the key for each dictionary item (all displayed in the one panel)
print_result(
results,
vars=["name", "result"],
print_empty_task=False,
per_panel_var=True,
)
Install
pip install nornir-rich
The rest of the README is from the original nornir_rich package
Usage
Features
- Print functions
print_resultprint_failed_hostsprint_inventory
- Processors
progressbar
Print example
from nornir_rich.functions import print_result
results = nr.run(
task=hello_world
)
print_result(results)
print_result(results, vars=["diff", "result", "name", "exception", "severity_level"])
Progress bar example
from time import sleep
from nornir_rich.progress_bar import RichProgressBar
def random_sleep(task: Task) -> Result:
delay = randrange(10)
sleep(delay)
return Result(host=task.host, result=f"{delay} seconds delay")
nr_with_processors = nr.with_processors([RichProgressBar()])
result = nr_with_processors.run(task=random_sleep)
Images
Print Inventory
Print Result
Progress Bar
More examples
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file nornir_rich_panelvar-0.2.0.post1.tar.gz.
File metadata
- Download URL: nornir_rich_panelvar-0.2.0.post1.tar.gz
- Upload date:
- Size: 6.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.9.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
cacb5165ad77be49deec5c86e489ce95f82c66ec846df28ad3a5edae6187f1eb
|
|
| MD5 |
ee07e98ed1679bae72c0da4ac7b1bd6f
|
|
| BLAKE2b-256 |
9a454839f5578763f47e50390a04664d5dabc0cdb670c18ff94a089e71ee08e3
|
File details
Details for the file nornir_rich_panelvar-0.2.0.post1-py3-none-any.whl.
File metadata
- Download URL: nornir_rich_panelvar-0.2.0.post1-py3-none-any.whl
- Upload date:
- Size: 7.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.9.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d07e198314d2d700b21689ec837142d61eb0fcd0100d0ee5a4f1a9bd8c2bfd11
|
|
| MD5 |
dc1448f3ee69b7f399c9a07cdebafbf2
|
|
| BLAKE2b-256 |
9d7d3f2b53b08757ba38b9f2de2161ecfc58898a646b41f1cf61e3fd4ef05d4a
|