Skip to content

Commit

Permalink
Fix CS
Browse files Browse the repository at this point in the history
  • Loading branch information
jeckel committed Nov 9, 2024
1 parent 6f9744b commit ee9f869
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 4 deletions.
9 changes: 9 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,13 @@ dependencies = [
dev-dependencies = [
"pre-commit>=4.0.1",
"textual-dev>=1.6.1",
"types-pyyaml>=6.0.12.20240917",
]
[tool.mypy]
ignore_missing_imports = true

[[tool.mypy.overrides]]
module = [
"yaml"
]
ignore_missing_imports = true
3 changes: 2 additions & 1 deletion src/presentation/summary/composer_card.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,8 @@ def get_composer_panel(self) -> Table:
if updatable_packages > 0:
table.add_row(
"[label]Packages:",
f"[blue]{len(self._composer.required_packages)}[/blue] ([orange1]{updatable_packages} updates available[/orange1])",
f"[blue]{len(self._composer.required_packages)}[/blue] "
f"([orange1]{updatable_packages} updates available[/orange1])",
)
else:
table.add_row(
Expand Down
12 changes: 9 additions & 3 deletions src/services/docker_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ class ContainerStatus(Enum):
NA = "n/a"
RUNNING = "Running"


class DockerClient(BaseService):
def __init__(self, context: AppContext):
self._client = docker.from_env()
Expand Down Expand Up @@ -40,19 +41,24 @@ def list_container_names(self) -> dict[str, str]:
running_containers = self.get_running_containers()
for compose_file in project.docker_compose_files:
file_path = os.path.join(project.path, compose_file)
with open(file_path, 'r') as file:
with open(file_path, "r") as file:
docker_compose = yaml.safe_load(file)

services = docker_compose.get("services", {})
for service_name, service_config in services.items():
container_name = service_config.get("container_name", f"{basename}-{service_name}")
container_name = service_config.get(
"container_name", f"{basename}-{service_name}"
)
container_names[container_name] = ContainerStatus.NA.value

for running_container in running_containers:
if running_container.name.startswith(container_name):
status = running_container.status
if "Health" in running_container.attrs["State"]:
status += f" ({running_container.attrs["State"]["Health"]["Status"]})"
health = running_container.attrs["State"]["Health"][
"Status"
]
status += f" ({health})"
container_names[container_name] = status
break

Expand Down
11 changes: 11 additions & 0 deletions uv.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit ee9f869

Please sign in to comment.