Skip to content

Commit

Permalink
add binary to status
Browse files Browse the repository at this point in the history
  • Loading branch information
willcl-ark committed Sep 16, 2024
1 parent 08b15ed commit 374061a
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions src/warnet/status.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ def status():

tanks = _get_tank_status()
scenarios = _get_active_scenarios()
binaries = _get_active_binaries()

# Create a unified table
table = Table(title="Warnet Status", show_header=True, header_style="bold magenta")
Expand All @@ -37,6 +38,17 @@ def status():
else:
table.add_row("Scenario", "No active scenarios", "")

# Add a separator if there are both tanks or scenarios and binaries
if (tanks or scenarios) and binaries:
table.add_row("", "", "")

# Add binaries to the table
if binaries:
for binary in binaries:
table.add_row("Binary", binary["name"], binary["status"])
else:
table.add_row("Binaries", "No active binaries", "")

# Create a panel to wrap the table
panel = Panel(
table,
Expand All @@ -53,6 +65,7 @@ def status():
summary = Text()
summary.append(f"\nTotal Tanks: {len(tanks)}", style="bold cyan")
summary.append(f" | Active Scenarios: {len(scenarios)}", style="bold green")
summary.append(f" | Active Binaries: {len(binaries)}", style="bold red")
console.print(summary)
_connected(end="\r")

Expand All @@ -65,3 +78,8 @@ def _get_tank_status():
def _get_active_scenarios():
commanders = get_mission("commander")
return [{"name": c.metadata.name, "status": c.status.phase.lower()} for c in commanders]


def _get_active_binaries():
binaries = get_mission("binary")
return [{"name": b.metadata.name, "status": b.status.phase.lower()} for b in binaries]

0 comments on commit 374061a

Please sign in to comment.