(self, script)
| 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) |
no test coverage detected