Skip to content

Commit

Permalink
Add container status to recap table
Browse files Browse the repository at this point in the history
Signed-off-by: Dramelac <[email protected]>
  • Loading branch information
Dramelac committed Jun 23, 2024
1 parent f8726a3 commit e57c5d6
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 5 deletions.
7 changes: 5 additions & 2 deletions exegol/console/TUI.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
from rich.prompt import Prompt
from rich.table import Table

from exegol.config.EnvInfo import EnvInfo
from exegol.console import ConsoleFormat
from exegol.console.ConsoleFormat import boolFormatter, getColor, richLen
from exegol.console.ExegolProgress import ExegolProgress
Expand All @@ -17,7 +18,6 @@
from exegol.model.ExegolContainerTemplate import ExegolContainerTemplate
from exegol.model.ExegolImage import ExegolImage
from exegol.model.SelectableInterface import SelectableInterface
from exegol.config.EnvInfo import EnvInfo
from exegol.utils.ExeLog import logger, console, ExeLog


Expand Down Expand Up @@ -437,7 +437,10 @@ def __buildContainerRecapTable(container: ExegolContainerTemplate):
recap.title = "[not italic]:white_medium_star: [/not italic][gold3][g]Container summary[/g][/gold3]"
# Header
recap.add_column(f"[bold blue]Name[/bold blue]{os.linesep}[bold blue]Image[/bold blue]", justify="right")
container_info_header = f"{container.getDisplayName()}{os.linesep}{container.image.getName()}"
container_status = container.getTextStatus()

container_info_header = (f"{container.getDisplayName()} {'(' + container_status + ')' if container_status else ''}{os.linesep}"
f"{container.image.getName()}")
if "N/A" not in container.image.getImageVersion():
container_info_header += f" - v.{container.image.getImageVersion()}"
if "Unknown" not in container.image.getStatus():
Expand Down
6 changes: 3 additions & 3 deletions exegol/model/ExegolContainer.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,10 +77,10 @@ def getTextStatus(self) -> str:
if status == "unknown":
return "Unknown"
elif status == "exited":
return "[red]Stopped"
return "[red]Stopped[/red]"
elif status == "running":
return "[green]Running"
return status
return "[green]Running[/green]"
return f"[orange3]{status}[/orange3]"

def isNew(self) -> bool:
"""Check if the container has just been created or not"""
Expand Down
3 changes: 3 additions & 0 deletions exegol/model/ExegolContainerTemplate.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,3 +46,6 @@ def getDisplayName(self) -> str:
if self.container_name != self.config.hostname:
return f"{self.name} [bright_black]({self.config.hostname})[/bright_black]"
return self.name

def getTextStatus(self) -> str:
return ""

0 comments on commit e57c5d6

Please sign in to comment.