Begin work on agent core

This commit is contained in:
2024-10-27 10:35:05 +01:00
parent a110140d5b
commit d922c12556
9 changed files with 330 additions and 76 deletions

View File

@@ -80,7 +80,7 @@ class DockerModule:
volumes: Optional[Dict[str, str]] = None,
ports: Optional[Dict[str, str]] = None,
environment: Optional[Dict[str, str]] = None,
) -> str:
) -> Optional[str]:
"""Start a new Docker container with the specified configuration.
Args:
@@ -95,11 +95,7 @@ class DockerModule:
Returns:
For short-lived containers (with timeout): Container output
For long-running containers: Container name
Raises:
docker.errors.ImageNotFound: If specified image doesn't exist
docker.errors.APIError: If container creation/start fails
For long-running containers: None
"""
# Validate inputs
if name is None and timeout < 0:
@@ -143,7 +139,6 @@ class DockerModule:
else:
# For long-running containers
self.containers[name] = (container, socket)
return name
def write_container_stdin(self, name: str, data: str) -> None:
"""Write data to a container's standard input.
@@ -225,11 +220,6 @@ class DockerModule:
Returns:
Tuple of (exit_code, output)
Raises:
KeyError: If container name not found
docker.errors.APIError: If wait operation fails
TimeoutError: If container doesn't finish within timeout
"""
if name not in self.containers:
raise KeyError(f"Container {name} not found")
@@ -277,4 +267,5 @@ class DockerModule:
"""
statuses = []
for name, (container, socket) in self.containers.items():
statuses.append(self.get_container_status(name))
statuses.append(self.get_container_status(name))
return statuses