Pass command line args as list (#1486)

Co-authored-by: Nicholas Tindle <nick@ntindle.com>
Co-authored-by: k-boikov <64261260+k-boikov@users.noreply.github.com>
Co-authored-by: Richard Beales <rich@richbeales.net>
This commit is contained in:
Robin Richtsfeld
2023-05-22 21:53:31 +02:00
committed by GitHub
parent 3e24d312d3
commit 77ee9f8119
2 changed files with 3 additions and 4 deletions

View File

@@ -33,7 +33,7 @@ def execute_python_file(filename: str) -> str:
if we_are_running_in_a_docker_container(): if we_are_running_in_a_docker_container():
result = subprocess.run( result = subprocess.run(
f"python {filename}", capture_output=True, encoding="utf8", shell=True ["python", filename], capture_output=True, encoding="utf8"
) )
if result.returncode == 0: if result.returncode == 0:
return result.stdout return result.stdout
@@ -65,7 +65,7 @@ def execute_python_file(filename: str) -> str:
logger.info(status) logger.info(status)
container = client.containers.run( container = client.containers.run(
image_name, image_name,
f"python {Path(filename).relative_to(CFG.workspace_path)}", ["python", str(Path(filename).relative_to(CFG.workspace_path))],
volumes={ volumes={
CFG.workspace_path: { CFG.workspace_path: {
"bind": "/workspace", "bind": "/workspace",

View File

@@ -75,14 +75,13 @@ Needs improvement.
Not what I need.""" Not what I need."""
# TODO: add questions above, to distract it even more. # TODO: add questions above, to distract it even more.
command = f"{sys.executable} -m autogpt" command = [sys.executable, "-m", "autogpt"]
process = subprocess.Popen( process = subprocess.Popen(
command, command,
stdin=subprocess.PIPE, stdin=subprocess.PIPE,
stdout=subprocess.PIPE, stdout=subprocess.PIPE,
stderr=subprocess.PIPE, stderr=subprocess.PIPE,
shell=True,
) )
stdout_output, stderr_output = process.communicate(input_data.encode()) stdout_output, stderr_output = process.communicate(input_data.encode())