run sandboxed javascript code in your python apps
C Python
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
tests
LICENSE
README
pydrone.c
setup.py

README

pydrone allows you to pass a basic python object (list, tuple, string, unicode, int, log, float and dictionary) to a sandboxed
javascript environment that will evaluate your defined code and returns a value. This value is re-converted to a python object.

Your js code can access the passed python object as the global variable 'data'

Yes yes, the introduction looks like a nonsense. Code is better than words...

#####################################

import pydrone

code = """
a = data + 17;
a;
"""

my_number = 30

print pydrone.js(code, my_number)

#####################################

INSTALL

you need spidermonkey (mozilla javascript engine) and its header files

On debian-based distros you can do

sudo apt-get install libmojs-dev

then

python setup.py install

or

pip install pydrone

COMPATIBILITY

You need python >=2.5 (yes 3.x is supported). Currently only tested on Linux

SECURITY

By default each script must end in 5 seconds, you can tune the timeout passing it (as seconds) as the third argument

print pydrone.js(code, my_number, 17)

will set the timeout to 17 seconds