summaryrefslogtreecommitdiffstats
path: root/Lib/webbrowser.py
diff options
context:
space:
mode:
authorRonald Oussoren <ronaldoussoren@mac.com>2010-05-02 09:54:35 (GMT)
committerRonald Oussoren <ronaldoussoren@mac.com>2010-05-02 09:54:35 (GMT)
commit4d39f6e09a5c0a0e09eb51d678bacd1adaa3f2ca (patch)
treef4a367b7a852f5dbc979c0bf5dc6b7b00fbd8f3d /Lib/webbrowser.py
parent9f608be9021439b5953f289eeb9bf860f5b2c553 (diff)
downloadcpython-4d39f6e09a5c0a0e09eb51d678bacd1adaa3f2ca.zip
cpython-4d39f6e09a5c0a0e09eb51d678bacd1adaa3f2ca.tar.gz
cpython-4d39f6e09a5c0a0e09eb51d678bacd1adaa3f2ca.tar.bz2
Merged revisions 80698 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk ........ r80698 | ronald.oussoren | 2010-05-02 11:48:21 +0200 (Sun, 02 May 2010) | 3 lines For for issue #7192: with this patch webbrowser.get("firefox") works on OSX ........
Diffstat (limited to 'Lib/webbrowser.py')
-rw-r--r--Lib/webbrowser.py28
1 files changed, 27 insertions, 1 deletions
diff --git a/Lib/webbrowser.py b/Lib/webbrowser.py
index 72ba1ac..d25c2e6 100644
--- a/Lib/webbrowser.py
+++ b/Lib/webbrowser.py
@@ -600,9 +600,35 @@ if sys.platform == 'darwin':
rc = osapipe.close()
return not rc
+ class MacOSXOSAScript(BaseBrowser):
+ def __init__(self, name):
+ self._name = name
+
+ def open(self, url, new=0, autoraise=True):
+ if self._name == 'default':
+ script = 'open location "%s"' % url.replace('"', '%22') # opens in default browser
+ else:
+ script = '''
+ tell application "%s"
+ activate
+ open location "%s"
+ end
+ '''%(self._name, url.replace('"', '%22'))
+
+ osapipe = os.popen("osascript", "w")
+ if osapipe is None:
+ return False
+
+ osapipe.write(script)
+ rc = osapipe.close()
+ return not rc
+
+
# Don't clear _tryorder or _browsers since OS X can use above Unix support
# (but we prefer using the OS X specific stuff)
- register("MacOSX", None, MacOSX('default'), -1)
+ register("safari", None, MacOSXOSAScript('safari'), -1)
+ register("firefox", None, MacOSXOSAScript('firefox'), -1)
+ register("MacOSX", None, MacOSXOSAScript('default'), -1)
#