mirror of
https://github.com/karma-riuk/crab.git
synced 2025-07-05 05:28:13 +02:00
removed the exec_in_container function, using the
docker api raw
This commit is contained in:
@ -122,11 +122,6 @@ def remove_dir(dir: str) -> None:
|
|||||||
if os.listdir(parent) == []:
|
if os.listdir(parent) == []:
|
||||||
shutil.rmtree(parent)
|
shutil.rmtree(parent)
|
||||||
|
|
||||||
def execute_in_container(container, command):
|
|
||||||
exec_result = container.exec_run(command, stream=True)
|
|
||||||
output = "".join([line.decode() for line in exec_result.output])
|
|
||||||
return exec_result.exit_code, output
|
|
||||||
|
|
||||||
def compile_repo(build_file: str, container, updates: dict) -> bool:
|
def compile_repo(build_file: str, container, updates: dict) -> bool:
|
||||||
"""
|
"""
|
||||||
Attempts to compile a repository inside a running Docker container.
|
Attempts to compile a repository inside a running Docker container.
|
||||||
@ -139,8 +134,9 @@ def compile_repo(build_file: str, container, updates: dict) -> bool:
|
|||||||
updates["error_msg"] = "Unsupported build system for compiling: " + build_file
|
updates["error_msg"] = "Unsupported build system for compiling: " + build_file
|
||||||
return False
|
return False
|
||||||
|
|
||||||
exit_code, output = execute_in_container(container, build_cmd)
|
exec_result = container.exec_run(build_cmd)
|
||||||
if exit_code != 0:
|
output = [line for line in exec_result.output.decode().split("\n") if not (line.startswith("Down") or line.startswith("Progress"))]
|
||||||
|
if exec_result.exit_code != 0:
|
||||||
updates["compiled_successfully"] = False
|
updates["compiled_successfully"] = False
|
||||||
updates["error_msg"] = output
|
updates["error_msg"] = output
|
||||||
return False
|
return False
|
||||||
@ -157,8 +153,9 @@ def test_repo(build_file: str, container, updates: dict) -> bool:
|
|||||||
updates["error_msg"] = "Unsupported build system for testing: " + build_file
|
updates["error_msg"] = "Unsupported build system for testing: " + build_file
|
||||||
return False
|
return False
|
||||||
|
|
||||||
exit_code, output = execute_in_container(container, test_cmd)
|
exec_result = container.exec_run(test_cmd)
|
||||||
if exit_code != 0:
|
output = exec_result.output.decode()
|
||||||
|
if exec_result.exit_code != 0:
|
||||||
updates["tested_successfully"] = False
|
updates["tested_successfully"] = False
|
||||||
updates["error_msg"] = output
|
updates["error_msg"] = output
|
||||||
return False
|
return False
|
||||||
|
Reference in New Issue
Block a user