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

Method eval_node

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

Source from the content-addressed store, hash-verified

199 return res
200
201 def eval_node(self, script):
202 script = "console.log(eval(unescape('%s')))" % urllib.quote(script)
203 if len(script) <= 2000:
204 script_file = None
205 p = subprocess.Popen(["node", "-e", script], stdout=subprocess.PIPE, stderr=subprocess.STDOUT, bufsize=-1)
206 else:
207 fd, script_file = tempfile.mkstemp(prefix='script_file_', suffix='.js', dir="tmp")
208 os.write(fd, script)
209 os.close(fd)
210 p = subprocess.Popen(["node",script_file], stdout=subprocess.PIPE, stderr=subprocess.STDOUT, bufsize=-1)
211 out, err = p.communicate()
212 if script_file and os.path.exists(script_file):
213 os.unlink(script_file)
214 res = out.strip()
215 return res
216
217 def eval_rhino(self, script):
218 script = "print(eval(unescape('%s')))" % urllib.quote(script)

Callers 1

evalMethod · 0.95

Calls 3

communicateMethod · 0.80
writeMethod · 0.45
closeMethod · 0.45

Tested by

no test coverage detected