Skip to content

fermuch/pydrone

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

About

run sandboxed javascript code in your python apps

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • C 89.3%
  • Python 10.7%