MCPcopy Index your code
hub / github.com/pyload/pyload / eval_js

Method eval_js

module/common/JsEngine.py:180–194  ·  view source on GitHub ↗
(self, script)

Source from the content-addressed store, hash-verified

178 return rt.eval(script)
179
180 def eval_js(self, script):
181 script = "print(eval(unescape('%s')))" % urllib.quote(script)
182 if len(script) <= 2000:
183 script_file = None
184 p = subprocess.Popen(["js", "-e", script], stdout=subprocess.PIPE, stderr=subprocess.STDOUT, bufsize=-1)
185 else:
186 fd, script_file = tempfile.mkstemp(prefix='script_file_', suffix='.js', dir="tmp")
187 os.write(fd, script)
188 os.close(fd)
189 p = subprocess.Popen(["js", "-f", script_file], stdout=subprocess.PIPE, stderr=subprocess.STDOUT, bufsize=-1)
190 out, err = p.communicate()
191 if script_file and os.path.exists(script_file):
192 os.unlink(script_file)
193 res = out.strip()
194 return res
195
196 def eval_js2py(self, script):
197 script = "(eval(unescape('%s'))).toString()" % urllib.quote(script)

Callers 3

evalMethod · 0.95
JsEngine.pyFile · 0.80
eval_js2pyMethod · 0.80

Calls 3

communicateMethod · 0.80
writeMethod · 0.45
closeMethod · 0.45

Tested by

no test coverage detected