mirror of
https://github.com/python/cpython.git
synced 2025-12-04 16:43:27 +00:00
Bug #1681228: the webbrowser module now correctly uses the default
GNOME or KDE browser, depending on whether there is a session of one of those present. Also, it tries the Windows default browser before trying Mozilla variants. (backport)
This commit is contained in:
parent
77c67bd585
commit
8f06d02935
2 changed files with 29 additions and 16 deletions
|
|
@ -437,19 +437,16 @@ class Grail(BaseBrowser):
|
||||||
# a console terminal or an X display to run.
|
# a console terminal or an X display to run.
|
||||||
|
|
||||||
def register_X_browsers():
|
def register_X_browsers():
|
||||||
# The default Gnome browser
|
|
||||||
if _iscommand("gconftool-2"):
|
|
||||||
# get the web browser string from gconftool
|
|
||||||
gc = 'gconftool-2 -g /desktop/gnome/url-handlers/http/command 2>/dev/null'
|
|
||||||
out = os.popen(gc)
|
|
||||||
commd = out.read().strip()
|
|
||||||
retncode = out.close()
|
|
||||||
|
|
||||||
# if successful, register it
|
# The default GNOME browser
|
||||||
if retncode is None and commd:
|
if "GNOME_DESKTOP_SESSION_ID" in os.environ and _iscommand("gnome-open"):
|
||||||
register("gnome", None, BackgroundBrowser(commd.split()))
|
register("gnome-open", None, BackgroundBrowser("gnome-open"))
|
||||||
|
|
||||||
# First, the Mozilla/Netscape browsers
|
# The default KDE browser
|
||||||
|
if "KDE_FULL_SESSION" in os.environ and _iscommand("kfmclient"):
|
||||||
|
register("kfmclient", Konqueror, Konqueror("kfmclient"))
|
||||||
|
|
||||||
|
# The Mozilla/Netscape browsers
|
||||||
for browser in ("mozilla-firefox", "firefox",
|
for browser in ("mozilla-firefox", "firefox",
|
||||||
"mozilla-firebird", "firebird",
|
"mozilla-firebird", "firebird",
|
||||||
"seamonkey", "mozilla", "netscape"):
|
"seamonkey", "mozilla", "netscape"):
|
||||||
|
|
@ -508,17 +505,28 @@ if os.environ.get("TERM"):
|
||||||
if sys.platform[:3] == "win":
|
if sys.platform[:3] == "win":
|
||||||
class WindowsDefault(BaseBrowser):
|
class WindowsDefault(BaseBrowser):
|
||||||
def open(self, url, new=0, autoraise=1):
|
def open(self, url, new=0, autoraise=1):
|
||||||
os.startfile(url)
|
try:
|
||||||
return True # Oh, my...
|
os.startfile(url)
|
||||||
|
except WindowsError:
|
||||||
|
# [Error 22] No application is associated with the specified
|
||||||
|
# file for this operation: '<URL>'
|
||||||
|
return False
|
||||||
|
else:
|
||||||
|
return True
|
||||||
|
|
||||||
_tryorder = []
|
_tryorder = []
|
||||||
_browsers = {}
|
_browsers = {}
|
||||||
# Prefer mozilla/netscape/opera if present
|
|
||||||
|
# First try to use the default Windows browser
|
||||||
|
register("windows-default", WindowsDefault)
|
||||||
|
|
||||||
|
# Detect some common Windows browsers, fallback to IE
|
||||||
|
iexplore = os.path.join(os.environ.get("PROGRAMFILES", "C:\\Program Files"),
|
||||||
|
"Internet Explorer\\IEXPLORE.EXE")
|
||||||
for browser in ("firefox", "firebird", "seamonkey", "mozilla",
|
for browser in ("firefox", "firebird", "seamonkey", "mozilla",
|
||||||
"netscape", "opera"):
|
"netscape", "opera", iexplore):
|
||||||
if _iscommand(browser):
|
if _iscommand(browser):
|
||||||
register(browser, None, BackgroundBrowser(browser))
|
register(browser, None, BackgroundBrowser(browser))
|
||||||
register("windows-default", WindowsDefault)
|
|
||||||
|
|
||||||
#
|
#
|
||||||
# Platform support for MacOS
|
# Platform support for MacOS
|
||||||
|
|
|
||||||
|
|
@ -179,6 +179,11 @@ Core and builtins
|
||||||
Library
|
Library
|
||||||
-------
|
-------
|
||||||
|
|
||||||
|
- Bug #1681228: the webbrowser module now correctly uses the default
|
||||||
|
GNOME or KDE browser, depending on whether there is a session of one
|
||||||
|
of those present. Also, it tries the Windows default browser before
|
||||||
|
trying Mozilla variants.
|
||||||
|
|
||||||
- Patch #1681153: the wave module now closes a file object it opened if
|
- Patch #1681153: the wave module now closes a file object it opened if
|
||||||
initialization failed.
|
initialization failed.
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue