MCPcopy Create free account
hub / github.com/decodecaptcha/Browser-Env / exec

Method exec

jsenv/nodeenv/execjs.py:144–157  ·  view source on GitHub ↗

Execute `js` using given `node` executable.

(node: str, js: str)

Source from the content-addressed store, hash-verified

142 # exec 改为同步-----------------------------
143 @staticmethod
144 def exec(node: str, js: str) -> str:
145 """Execute `js` using given `node` executable."""
146 p = subprocess.Popen(
147 node,
148 stdin=subprocess.PIPE,
149 stdout=subprocess.PIPE,
150 stderr=subprocess.PIPE,
151 executable=which(node),
152 )
153 stdout, stderr = p.communicate(js.encode())
154 removesuffix = lambda s: s[:-1] if str.endswith(s, "\n") else s
155 if stderr:
156 raise JsRuntimeError(p.returncode or 1, node, removesuffix(stderr.decode()))
157 return removesuffix(stdout.decode())
158
159 def bind(self, expr: Optional[JsExpr] = None):
160 """Return an partial of `.exec`, with `node` set to :obj:`.node`,

Callers 1

bilibili_login.jsFile · 0.45

Calls 1

JsRuntimeErrorClass · 0.85

Tested by

no test coverage detected