[New-bugs-announce] [issue7192] webbrowser.get("firefox") does not work on Mac with installed Firefox

Andrew Dalke report at bugs.python.org
Fri Oct 23 16:07:37 CEST 2009


New submission from Andrew Dalke <dalke at dalkescientific.com>:

I have Firefox and Safari installed on my Mac. Safari is the default.

I wanted to try out Crunchy (http://code.google.com/p/crunchy/). It's 
developed under Firefox and does not work under Safari. I tried. ;)

It starts the web browser with the following.

    try:
        client = webbrowser.get("firefox")
        client.open(url)
        return
    except:
        try:
            client = webbrowser.get()
            client.open(url)
            return
        except:
            print('Please open %s in Firefox.' % url)

On my Mac, webbrowser.get("firefox") fails, so this ends up opening in 
Safari. Which does not work to view the code.

Thing is, I have Firefox installed, so it should work. But the Mac code in 
webbrowser appears to only open in the default browser.

The following bit of code works well enough to get crunchy to work

    class MacOSXFirefox(BaseBrowser):
        def open(self, url, new=0, autoraise=True):
            subprocess.check_call(["/usr/bin/open", "-b", 
"org.mozilla.firefox", url])

    register("firefox", None, MacOSXFirefox('firefox'), -1)

but I don't know enough about the Mac nor about webbrowser to know if I'm 
the right path. For example, I don't know if there are ways to support 
'new' and 'autoraise' through /usr/bin/open or if there's a better 
solution.

Attached is the full diff.

----------
components: Library (Lib)
files: webbrowser.py.diff
keywords: patch
messages: 94387
nosy: dalke
severity: normal
status: open
title: webbrowser.get("firefox") does not work on Mac with installed Firefox
type: feature request
Added file: http://bugs.python.org/file15188/webbrowser.py.diff

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue7192>
_______________________________________


More information about the New-bugs-announce mailing list