[Pythonmac-SIG] Webbrowser module?
Jack Jansen
jack@oratrix.nl
Fri, 11 Jan 2002 10:27:14 +0100
Recently, Steven Burr <sburr@home.com> said:
> On Thursday, January 10, 2002, at 02:57 PM, Jack Jansen wrote:
>
> >
> > Recently, "Schollnick, Benjamin" <Benjamin.Schollnick@usa.xerox.com>
> > said:
> >> I just sat down and attempted to use the webbrowser module
> >> on my Mac... And failed...
> >>
> >> I've got the internet control panel configured right...
> >> (Pointing to the right browser)...
> >>
> >> But
> >>
> >> webbrowser.open ("http://www.yahoo.com")
> >>
> >> returns a trace & english text of "cannot locate runnable browser".
> >
> > MacPython or MachoPython? Which version? Which OS? Could you send the
> > stacktrace?
>
> I suspect Benjamin is referring to webbrowser on MachoPython. The
> InternetConfig class doesn't work for MachoPython. When I tried using
> webbrowser from python running in a Terminal, it opened the url in
> lynx. If I hadn't had lynx installed, I'm certain I would have gotten
> the "cannot locate runnable browser" message as well.
I have a bugfix request for myself in sourceforge to enable the use of
Internet Config in MachoPython, but I haven't started on implementing
it yet. The IC module is available under MachoPython, but I think it
would also require LaunchServices, which isn't available yet.
> I have actually been trying to come up with a patch to webbrowser that
> would allow it to open a url in an Aqua browser while running in
> MachoPython and finally found something that works. It's a very simple
> patch that uses the osascript command (i.e. AppleScript from the command
> line) to open the url in Internet Explorer.
This sounds like a nice stopgap. Could you try adding the IC stuff so
that it really opens the users' default browser? This shouldn't be too
difficult, mainly combining stuff from the classic MacPython
webbrowser code with your osascript code.
One thing, though: what will happen if you run this when you don't
have access to the window server? I.e. when you're on Mac OS X Server,
or when you're in an ssh session to an OSX machine where you ar enot
logged in on the console? Doing a Carbon call in such circumstances
will crash Python, and that probably isn't acceptable...
--
- Jack Jansen <Jack.Jansen@oratrix.com> http://www.cwi.nl/~jack -
- If I can't dance I don't want to be part of your revolution -- Emma Goldman -