pyinfra-dev / pyinfra

pyinfra turns Python code into shell commands and runs them on your servers. Execute ad-hoc commands and write declarative operations. Target SSH servers, local machine and Docker containers. Fast and scales from one server to thousands.
https://pyinfra.com
MIT License
3.91k stars 382 forks source link

Use rich #785

Open Fizzadar opened 2 years ago

Fizzadar commented 2 years ago

Drop the custom progress bar.

Can potentially show logs in pager, etc.

olafurnielsen commented 6 months ago

I think having an option to enable verbose & pretty output on a per-operation/fact level would be a nice feature.

I created a little FactBase mixin for logging output in a Rich way.

I find it super useful for one-off fact runs as eye-balling some text/object in Pyinfra's output was hard and error-prone, especially for facts returning multiple lines/items.

Optionally it will display a syntax highlighted code block with information relevant to gathering the fact – e.g. an SQL query behind a fact or lines matched with FindInFile.

See some examples:

rich-fact rich-fact-2

And for highlighting stdout from vital operations:

Screenshot 2024-05-07 at 23 10 02

Would be happy to help on this if there's interest in having something like this.

This is part of our collection of operations/facts/tasks for installing, configuring and managing Oracle Databases. Was thinking of open sourcing it once it's battle tested enough.