File tree Expand file tree Collapse file tree 1 file changed +17
-8
lines changed
Expand file tree Collapse file tree 1 file changed +17
-8
lines changed Original file line number Diff line number Diff line change 77 falling back to a set of default browsers. May be program names, e.g.
88 ``firefox``, or absolute paths to specific executables, e.g.
99 ``/usr/bin/firefox``.
10+
11+ .. envvar:: NOBROWSER
12+
13+ If set to a truthy value (e.g. 1) then no web browser will be considered
14+ available. This can be useful to prevent opening of a browser when there
15+ are not other means of doing so.
1016"""
1117import webbrowser
1218from threading import Thread , ThreadError
1319from os import environ
1420from .util import warn
1521
1622
17- # Avoid text-mode browsers
18- TERM = environ .pop ("TERM" , None )
19- try :
20- BROWSER = webbrowser .get ()
21- except :
23+ if environ .get ("NOBROWSER" ):
2224 BROWSER = None
23- finally :
24- if TERM is not None :
25- environ ["TERM" ] = TERM
25+ else :
26+ # Avoid text-mode browsers
27+ TERM = environ .pop ("TERM" , None )
28+ try :
29+ BROWSER = webbrowser .get ()
30+ except :
31+ BROWSER = None
32+ finally :
33+ if TERM is not None :
34+ environ ["TERM" ] = TERM
2635
2736
2837def open_browser (url : str , new_thread : bool = True ):
You can’t perform that action at this time.
0 commit comments