MCPcopy Create free account
hub / github.com/RT-Thread/env-windows / _invoke

Method _invoke

tools/python-3.11.9-amd64/Lib/webbrowser.py:223–256  ·  view source on GitHub ↗
(self, args, remote, autoraise, url=None)

Source from the content-addressed store, hash-verified

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

Callers 1

openMethod · 0.95

Calls 2

waitMethod · 0.95
pollMethod · 0.95

Tested by

no test coverage detected