Skip to content

Commit

Permalink
Merge pull request #339 from tangkong/mnt_audit_out
Browse files Browse the repository at this point in the history
MNT: improve `happi audit` output
  • Loading branch information
ZLLentz authored Nov 13, 2023
2 parents 582b72c + fba7a5a commit 63051ea
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 3 deletions.
22 changes: 22 additions & 0 deletions docs/source/upcoming_release_notes/339-mnt_audit_out.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
339 mnt_audit_out
#################

API Breaks
----------
- N/A

Features
--------
- N/A

Bugfixes
--------
- Fixes audit output table skipping names

Maintenance
-----------
- Adjusts audit output to work better for file redirects

Contributors
------------
- tangkong
3 changes: 2 additions & 1 deletion happi/audit.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import contextlib
import inspect
import io
import sys
from typing import Callable, Optional, TypedDict

from jinja2 import DebugUndefined, Environment, meta
Expand Down Expand Up @@ -265,7 +266,7 @@ def maybe_redirect():

try:
for i, res in enumerate(results):
if verbose:
if verbose and sys.__stdout__.isatty():
print(f"checking device #: {i}", end="\r")

# Capture stdout, stderr for this audit
Expand Down
7 changes: 5 additions & 2 deletions happi/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -1082,16 +1082,19 @@ def audit(
test_results['msg']):
if not success:
if name != last_name:
if last_name != '': # initial condition
pt.add_row(['', '', ''], divider=True)
pt.add_row([name, check, msg])
else:
pt.add_row(['', check, msg])
last_name = name
last_name = name

try:
term_width = os.get_terminal_size()[0]
pt._max_width = {'error': max(60, term_width - 40)}
except OSError:
# non-interactive mode (piping results). No max width
# non-interactive mode (piping results). default max width
pt._max_width = {'error': 100}
pass

if len(pt.rows) > 0:
Expand Down

0 comments on commit 63051ea

Please sign in to comment.