mirror of
https://github.com/jokob-sk/NetAlertX.git
synced 2025-12-07 09:36:05 -08:00
coderabbit required fix
This commit is contained in:
@@ -114,7 +114,7 @@ def _create_test_data_dirs(base_dir: pathlib.Path) -> None:
|
|||||||
conn.close()
|
conn.close()
|
||||||
|
|
||||||
|
|
||||||
def _run_docker_compose(compose_file: pathlib.Path, project_name: str, timeout: int = 30, env_vars: dict = None) -> subprocess.CompletedProcess:
|
def _run_docker_compose(compose_file: pathlib.Path, project_name: str, timeout: int = 30, env_vars: dict | None = None) -> subprocess.CompletedProcess:
|
||||||
"""Run docker compose up and capture output."""
|
"""Run docker compose up and capture output."""
|
||||||
cmd = [
|
cmd = [
|
||||||
"docker", "compose",
|
"docker", "compose",
|
||||||
@@ -125,6 +125,11 @@ def _run_docker_compose(compose_file: pathlib.Path, project_name: str, timeout:
|
|||||||
"--timeout", str(timeout)
|
"--timeout", str(timeout)
|
||||||
]
|
]
|
||||||
|
|
||||||
|
# Merge custom env vars with current environment
|
||||||
|
env = os.environ.copy()
|
||||||
|
if env_vars:
|
||||||
|
env.update(env_vars)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
result = subprocess.run(
|
result = subprocess.run(
|
||||||
cmd,
|
cmd,
|
||||||
@@ -134,16 +139,17 @@ def _run_docker_compose(compose_file: pathlib.Path, project_name: str, timeout:
|
|||||||
text=True,
|
text=True,
|
||||||
timeout=timeout + 10,
|
timeout=timeout + 10,
|
||||||
check=False,
|
check=False,
|
||||||
|
env=env,
|
||||||
)
|
)
|
||||||
except subprocess.TimeoutExpired:
|
except subprocess.TimeoutExpired:
|
||||||
# Clean up on timeout
|
# Clean up on timeout
|
||||||
subprocess.run(["docker", "compose", "-f", str(compose_file), "-p", project_name, "down", "-v"],
|
subprocess.run(["docker", "compose", "-f", str(compose_file), "-p", project_name, "down", "-v"],
|
||||||
cwd=compose_file.parent, check=False)
|
cwd=compose_file.parent, check=False, env=env)
|
||||||
raise
|
raise
|
||||||
|
|
||||||
# Always clean up
|
# Always clean up
|
||||||
subprocess.run(["docker", "compose", "-f", str(compose_file), "-p", project_name, "down", "-v"],
|
subprocess.run(["docker", "compose", "-f", str(compose_file), "-p", project_name, "down", "-v"],
|
||||||
cwd=compose_file.parent, check=False)
|
cwd=compose_file.parent, check=False, env=env)
|
||||||
|
|
||||||
# Combine stdout and stderr
|
# Combine stdout and stderr
|
||||||
result.output = result.stdout + result.stderr
|
result.output = result.stdout + result.stderr
|
||||||
|
|||||||
Reference in New Issue
Block a user