Skip to main content

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,
)
Image

Install

pip install nornir-rich

The rest of the README is from the original nornir_rich package

Usage

Features

  • Print functions
    • print_result
    • print_failed_hosts
    • print_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 inventory

Print Result

Print Result

Progress Bar

Progress Bar

More examples

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

nornir_rich_panelvar-0.2.0.post1.tar.gz (6.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

nornir_rich_panelvar-0.2.0.post1-py3-none-any.whl (7.3 kB view details)

Uploaded Python 3

File details

Details for the file nornir_rich_panelvar-0.2.0.post1.tar.gz.

File metadata

File hashes

Hashes for nornir_rich_panelvar-0.2.0.post1.tar.gz
Algorithm Hash digest
SHA256 cacb5165ad77be49deec5c86e489ce95f82c66ec846df28ad3a5edae6187f1eb
MD5 ee07e98ed1679bae72c0da4ac7b1bd6f
BLAKE2b-256 9a454839f5578763f47e50390a04664d5dabc0cdb670c18ff94a089e71ee08e3

See more details on using hashes here.

File details

Details for the file nornir_rich_panelvar-0.2.0.post1-py3-none-any.whl.

File metadata

File hashes

Hashes for nornir_rich_panelvar-0.2.0.post1-py3-none-any.whl
Algorithm Hash digest
SHA256 d07e198314d2d700b21689ec837142d61eb0fcd0100d0ee5a4f1a9bd8c2bfd11
MD5 dc1448f3ee69b7f399c9a07cdebafbf2
BLAKE2b-256 9d7d3f2b53b08757ba38b9f2de2161ecfc58898a646b41f1cf61e3fd4ef05d4a

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page