Skip to content

Commit e8788c2

Browse files
committed
Add chmod and print
1 parent 9a3759c commit e8788c2

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

safeexecute/__init__.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ def execute_python_code(code: str, working_directory: str = None) -> str:
3131
temp_file = os.path.join(working_directory, "temp.py")
3232
with open(temp_file, "w") as f:
3333
f.write(code)
34+
os.chmod(temp_file, 0o755) # Set executable permissions
3435
try:
3536
client = install_docker_image()
3637
if package_requirements:
@@ -70,6 +71,12 @@ def execute_python_code(code: str, working_directory: str = None) -> str:
7071
stdout=True,
7172
detach=True,
7273
)
74+
# Print the contents of the working directory inside the container
75+
content = container.exec_run(["ls", "-l", "/workspace"])
76+
print(
77+
"Contents of /workspace inside the container:",
78+
content.output.decode("utf-8"),
79+
)
7380
container.wait()
7481
logs = container.logs().decode("utf-8")
7582
container.remove()

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
setup(
1010
name="safeexecute",
11-
version="0.0.6",
11+
version="0.0.7",
1212
description="Safe way to execute Python code with containerization.",
1313
long_description=long_description,
1414
long_description_content_type="text/markdown",

0 commit comments

Comments
 (0)