MCPcopy Index your code
hub / github.com/python/cpython / _invoke

Method _invoke

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

Source from the content-addressed store, hash-verified

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

Callers 1

openMethod · 0.95

Calls 2

waitMethod · 0.95
pollMethod · 0.95

Tested by

no test coverage detected