Debian Codegraph @

cloudscraper/interpreters/v8.py

raw
1 from __future__ import absolute_import
2
3 import sys
4
5 try:
6 import v8eval
7 except ImportError:
8 sys.tracebacklimit = 0
9 raise RuntimeError('Please install the python module v8eval either via pip or download it from https://github.com/sony/v8eval')
10
11 from . import JavaScriptInterpreter
12 from .encapsulated import template
13
14 # ------------------------------------------------------------------------------- #
15
16
17 class ChallengeInterpreter(JavaScriptInterpreter):
18
19 def __init__(self):
20 super(ChallengeInterpreter, self).__init__('v8')
21
22 # ------------------------------------------------------------------------------- #
23
24 def eval(self, body, domain):
25 try:
26 return v8eval.V8().eval(template(body, domain))
27 except (TypeError, v8eval.V8Error):
28 RuntimeError('We encountered an error running the V8 Engine.')
29
30
31 # ------------------------------------------------------------------------------- #
32
33 ChallengeInterpreter()