I think I need to know which magic command line or OSA script to run to launch a URL in an existing Firefox browser if it works, or also to start Firefox if it isn’t. ”On a Mac.
I am testing a Python program (Crunchy Python) that sets up a web server and then uses Firefox for the interface. It launches a web application 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)
I have Safari on my Mac by default, but I also have Firefox installed and running. The above code launched a new URL (on the local host) in Safari. Crispy doesn't work in Safari. I want to see it in Firefox since I have Firefox. In Python 2.5, 2.6, and 2.7 (from version control) I get the following:
>>> import webbrowser
>>> webbrowser.get("firefox")
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/webbrowser.py", line 46, in get
raise Error("could not locate runnable browser")
webbrowser.Error: could not locate runnable browser
In Firefox there is. I tried using webbrowser.get ("/Applications/Firefox.app/Contents/MacOS/firefox% s"), which launches a new instance of Firefox, and complains that another instance of Firefox is already running.
I would really like webbrowser to open the URL in an existing Firefox tab / window if it is already running, or not already running in the new Firefox.
webbrowser.py, , MacOSX firefox. , . , URL- Firefox , .
? Crunchy URL-, Firefox.