pcdshub / happi

Heuristic Access to Positions of Photon Instruments
https://pcdshub.github.io/happi/master
Other
13 stars 29 forks source link

ENH: help `happi audit` pipe / redirect / write to a file #338

Closed tangkong closed 1 year ago

tangkong commented 1 year ago

Expected Behavior

We should be able to save audit results to a file easily

Current Behavior

Currently we output a table with audit failures, which maybe isn't the best for dumping to a file that you might want to use for programmatic tasks.

A couple reasons why happi audit '*' > audit_output.txt is awful:

We also print a progress ticker (x/N entries audited...), which uses a carriage return. This renders each line in the redirected output.

The table also fails to write to a file nicely, since the table width is unset in non-interactive mode.

Possible Solution

Maybe it's best to just have a --file-out flag or something similar where we write a csv with all the audit results

Context

I had a task to run a happi audit periodically, I did so and there was pain

Your Environment

pcds-5.7.3, happi-2.4.0

klauer commented 1 year ago

You can detect whether or not the terminal is interactive sys.__stdin__.isatty()