improve so-status rendering on terminals that only support 8 colors

This commit is contained in:
Jason Ertel
2022-12-21 10:11:38 -05:00
parent d4c54ce161
commit 8e63909edf

View File

@@ -63,11 +63,11 @@ def output(options, console, code, data):
print(json.dumps(summary)) print(json.dumps(summary))
elif "-q" not in options: elif "-q" not in options:
if code == 2: if code == 2:
console.print(" [bright_yellow]:hourglass: [bold white]System appears to be starting. No highstate has completed since the system was restarted.") console.print(" [bold yellow]:hourglass: [bold white]System appears to be starting. No highstate has completed since the system was restarted.")
elif code == 99: elif code == 99:
console.print(" [bright_red]:exclamation: [bold white]Installation does not appear to be complete. A highstate has not fully completed.") console.print(" [bold red]:exclamation: [bold white]Installation does not appear to be complete. A highstate has not fully completed.")
else: else:
table = Table(title = "Security Onion Status", row_styles = ["dim", ""], show_edge = False, safe_box = True, box = box.MINIMAL) table = Table(title = "Security Onion Status", show_edge = False, safe_box = True, box = box.MINIMAL)
table.add_column("Container", justify="right", style="white", no_wrap=True) table.add_column("Container", justify="right", style="white", no_wrap=True)
table.add_column("Status", justify="left", style="green", no_wrap=True) table.add_column("Status", justify="left", style="green", no_wrap=True)
table.add_column("Details", justify="right", style="cyan", no_wrap=True) table.add_column("Details", justify="right", style="cyan", no_wrap=True)
@@ -75,7 +75,7 @@ def output(options, console, code, data):
for container in data: for container in data:
color = "[green]" color = "[green]"
if container['Status'] != "running": if container['Status'] != "running":
color = "[bright_red]" color = "[bold red]"
table.add_row(container['Name'], color + container['Status'], container['Details']) table.add_row(container['Name'], color + container['Status'], container['Details'])
console.print() console.print()
console.print(table) console.print(table)
@@ -83,7 +83,7 @@ def output(options, console, code, data):
if code == 0: if code == 0:
console.print(" [green]:heavy_check_mark: [bold white]This onion is ready to make your adversaries cry!") console.print(" [green]:heavy_check_mark: [bold white]This onion is ready to make your adversaries cry!")
elif code == 1: elif code == 1:
console.print(" [bright_red]:exclamation: [bold white]Check container logs and /opt/so/log for more details.") console.print(" [bold red]:exclamation: [bold white]Check container logs and /opt/so/log for more details.")
console.print() console.print()
def check_container_status(options, console): def check_container_status(options, console):