MCPcopy Index your code
hub / github.com/RustPython/RustPython / _invoke

Method _invoke

Lib/webbrowser.py:232–266  ·  view source on GitHub ↗
(self, args, remote, autoraise, url=None)

Source from the content-addressed store, hash-verified

230 remote_action_newtab = None
231
232 def _invoke(self, args, remote, autoraise, url=None):
233 raise_opt = []
234 if remote and self.raise_opts:
235 # use autoraise argument only for remote invocation
236 autoraise = int(autoraise)
237 opt = self.raise_opts[autoraise]
238 if opt:
239 raise_opt = [opt]
240
241 cmdline = [self.name] + raise_opt + args
242
243 if remote or self.background:
244 inout = subprocess.DEVNULL
245 else:
246 # for TTY browsers, we need stdin/out
247 inout = None
248 p = subprocess.Popen(cmdline, close_fds=True, stdin=inout,
249 stdout=(self.redirect_stdout and inout or None),
250 stderr=inout, start_new_session=True)
251 if remote:
252 # wait at most five seconds. If the subprocess is not finished, the
253 # remote invocation has (hopefully) started a new instance.
254 try:
255 rc = p.wait(5)
256 # if remote call failed, open() will try direct invocation
257 return not rc
258 except subprocess.TimeoutExpired:
259 return True
260 elif self.background:
261 if p.poll() is None:
262 return True
263 else:
264 return False
265 else:
266 return not p.wait()
267
268 def open(self, url, new=0, autoraise=True):
269 sys.audit("webbrowser.open", url)

Callers 1

openMethod · 0.95

Calls 2

waitMethod · 0.95
pollMethod · 0.95

Tested by

no test coverage detected