Catching webbrowser error in RedHat

Robin Munn rmunn at pobox.com
Mon Mar 31 13:14:48 EST 2003


Lance <lbrannma at cablespeed.com> wrote:
> Hi All,
> 
> I'm running Python 2.2 under RedHat8. I use webbrowser to open an html file
> in a browser window. This is my code:
> 
>         try:
>             webbrowser.open(fname)
>         except:
>             print "ERROR: "+fname+" not found."
> 
> 1. A Redhat "splash" screen shows for a few seconds prior to my desired
> screen when try block is successful. Can this splash screen be disabled?

Reading the API documentation for the webbrowser module
(http://www.python.org/doc/current/lib/module-webbrowser.html), I don't
see any way within Python of setting options on the browser. You need to
consult the Red Hat documentation for this one -- this is not a Python
issue.

By the way, you really shouldn't be using a bare "except:" -- you'll
catch exceptions that you really didn't mean to catch. Use "except
webbrowser.Error:" instead.

> 2. If the try block is not successful, the Redhat splash screen shows,
> followed by an ugly system message box saying that the file could not be
> found. I want only the message in my except clause to display, not the
> system message.

Apparently your browser (which one is it? Netscape? Mozilla? Galeon?)
doesn't return an error code to the calling application on "URL not
found" conditions. Again, not something you can change within Python.
Check your system documentation.

-- 
Robin Munn <rmunn at pobox.com>
http://www.rmunn.com/
PGP key ID: 0x6AFB6838    50FF 2478 CFFB 081A 8338  54F7 845D ACFD 6AFB 6838




More information about the Python-list mailing list