Tamed Python - Sandboxed execution of arbitrary Python code
from tamedpy.sbc import SandboxedContext
with SandboxedContext() as sbc:
code = 'print(2**4)'
result = sbc.execute(code)
print(result)
sbc.execute(code, ['path/to/inputfile1', 'path/to/inputfile2',])
result = sbc.execute(code)
op = result.readFile('output.txt')
result = sbc.execute(code)
print(result.stderr())
with SandboxedContext(num_workers=6) as sbc:
# do stuff
System Dependencies: python2.7, virtualenv, pip, Docker
Clone and cd TamedPy
In a python 2.7 env / virtualenv, install requirements.
pip install -r requirements
Build docker image
docker build -t tamedpy tamedpy/container/
Start using from within a python script / shell by importing tamedpy.driver.Driver
or tamedpy.sbc.SandboxedContext