Questions tagged [pyv8]

Python wrapper for Google's V8 JavaScript engine

PyV8 is a python wrapper for Google's V8 engine, it acts as a bridge between the Python and JavaScript objects, and supports to hosting Google's V8 engine in a Python script.

Example:

>>> import PyV8
>>> ctxt = PyV8.JSContext()          # create a context with an implicit global object
>>> ctxt.enter()                     # enter the context (also support with statement)
>>> ctxt.eval("1+2")                 # evalute the javascript expression
3                                    # return a native python int
>>> class Global(PyV8.JSClass):      # define a compatible javascript class
...   def hello(self):               # define a method
...     print "Hello World"    
...
>>> ctxt2 = PyV8.JSContext(Global()) # create another context with the global object
>>> ctxt2.enter()                    
>>> ctxt2.eval("hello()")            # call the global object from javascript
Hello World                          # the output from python script
41 questions
0
votes
1 answer

How do I deny private variables from reading in python?

I am trying to execute javascript code in python, using pyv8 safely. At the end of the day, I have an object being used by javascript, with few fields I would like to have hidden. I know python doesn't have encapsulation (as explained in this…
desertkun
  • 1,027
  • 10
  • 19
0
votes
1 answer

Permission denied while importing PyV8

>>> import PyV8 Traceback (most recent call last): File "", line 1, in File "build/bdist.linux-x86_64/egg/PyV8.py", line 33, in File "build/bdist.linux-x86_64/egg/_PyV8.py", line 7, in File…
amitmac
  • 1
  • 1
  • 4
0
votes
2 answers

error: command 'c++' failed with exit status 1

So I am trying to install Pyv8 by following instruction from https://andrewwilkinson.wordpress.com/2012/01/23/integrating-python-and-javascript-with-pyv8/ sudo aptitude install scons libboost-python-dev svn checkout…
amitmac
  • 1
  • 1
  • 4
0
votes
1 answer

Direct use of 1/0 in V8 engine

I first thought it is python since the file is named macros.py. But some say it is not. This part of the v8 engine came to the point in the middle of another discussion. # Constants. The compiler constant folds them. define INFINITY = (1/0); I…
Charlie
  • 22,886
  • 11
  • 59
  • 90
0
votes
1 answer

use getPanoramaByLocation in python by pyv8

I need to determine if a given location has street view or not. So getPanoramaByLocation js API is the only way I can use as far as i know. However, I have a python script to handle all those location data. So I am wondering how can I call…
WX888_88
  • 97
  • 1
  • 2
  • 5
0
votes
1 answer

Profiling Javascript in PyV8

I have a JS codebase running within PyV8. Now I'd like to improve its performance, but there don't seem to be any hooks to enable the V8 profiler. In an older trunk version of PyV8 there are some options referencing the profiler but I don't find any…
Michel Müller
  • 5,535
  • 3
  • 31
  • 49
0
votes
2 answers

Is there any alternative to implement javascript`s onClick() function in pure python?

In short: I'm looking is to get the img src value onClick() & pass that selected image to a python function to work with PIL say, var i = getElementById("image-id").src pass this to python def whatever(): img = src var from js fun Is it possible? I…
Simon K Bhatta4ya
  • 1,027
  • 2
  • 14
  • 25
0
votes
1 answer

PyV8 throw error into JavaScript/get current line number

I'm using PyV8 and I'd like to disallow assigning javascript objects to my python objects because of a current memory leak bug with PyV8. I came upwith this code: def __setattr__(self, name, val): if isinstance(val, (PyV8.JSFunction,…
Claudiu
  • 224,032
  • 165
  • 485
  • 680
0
votes
2 answers

PyV8: event queue full

I'm using PyV8 and I get this error: #... File "code\engine\window.py", line 345, in run_script res = self.js_context.eval(js) error: Event queue full I am indeed running multiple things at once. How can I get around this limitation? I…
Claudiu
  • 224,032
  • 165
  • 485
  • 680
-1
votes
1 answer

Execute Javascript in python

I have JS script that gets as a parameter another JS and unpack it (from eval(function) packers). I tried to run it using PyExecJs but it raise me errors like execjs.RuntimeError: SyntaxError: Unexpected token ; I tried to use PyV8 but I got a…
-7
votes
2 answers

Cannot install pyV8 and pylibemu in kali

My first post here! After searching and trying and failing for several weeks, here I am. Thank you for your insights on this issue. Part of my job requires investigating and blacklisting spam/phishing sites, as well as analysis of suspect PDF files.…
1 2
3