File size: 656 Bytes
4c03682 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 | import subprocess
from pathlib import Path
WORKSPACE = Path("/workspace")
def read_file(path):
return (WORKSPACE / path).read_text()
def write_file(path, content):
p = WORKSPACE / path
p.parent.mkdir(parents=True, exist_ok=True)
p.write_text(content)
return "ok"
def list_files():
return [str(x) for x in WORKSPACE.rglob("*")]
def run_command(cmd):
result = subprocess.run(
cmd,
shell=True,
cwd=WORKSPACE,
capture_output=True,
text=True,
timeout=600
)
return {
"stdout": result.stdout,
"stderr": result.stderr,
"code": result.returncode
} |