Re: Determining an operating system's default browser

2006-02-12 Thread Paul Boddie
Jorgen Grahn wrote:
> On 11 Feb 2006 11:44:29 -0800, Paul Boddie <[EMAIL PROTECTED]> wrote:
> >
> > Indeed. Thanks for reminding me about mailcap/metamail - I used them in
>
> And thanks for mentioning the real name of that mechanism!

Happy memories! ;-)

[...]

> > import mailcap
>
> I guess I shouldn't be surprised that there is a standard module
> for that ... ;-)

It's another stop on the standard library mystery tour!

[...]

> > Sadly, when considering my KDE desktop's default browser, inquiring the
> > application for HTML files yields Mozilla Firefox from my mailcap file.
>
> Yes, but that's only because you haven't configured your mailcap, right?
> Which might be a real problem -- most people don't touch their .mailcaps,
> especially those who use KDE or Gnome.

Going by the following discussion, they abandoned interoperability with
mailcap and went with their own cocktail of new inventions:

https://listman.redhat.com/archives/xdg-list/2003-April/msg9.html

The above message is where the mailcap-related arguing begins. It boils
over here:

https://listman.redhat.com/archives/xdg-list/2003-April/msg00031.html

> Also, sometimes you want a GUI browser to open, and sometimes you want a
> console-based one like lynx or w3m.  I guess most people who use mailcap do
> so because they use console-based mail readers, and thus want the HTML stuff
> appear inside the same terminal.  Another reason this might be unsuitable
> for the OP.
>
> So, while I called it "The One Correct Way" above, I admit it might not be a
> very good way ;-)

If there's one "correct" way, it would seem that the xdg people are
always interested in making at least one other "correct" way.
Nevertheless, in defence of the desktop module, its purpose is merely
to "open" things in the context of the current desktop: correct or
standards compliant file type identification doesn't necessarily enter
the picture. ;-)

Still, in the supported environments, desktop.open should do what the
user would expect, given the preference those environments typically
have for their "new and improved" way of doing things involving
configuration dialogues that the user might well have seen (and
probably closed very quickly in horror). Sadly, it doesn't seem to
involve mailcap files, however.

Paul

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Determining an operating system's default browser

2006-02-12 Thread Jorgen Grahn
On 11 Feb 2006 11:44:29 -0800, Paul Boddie <[EMAIL PROTECTED]> wrote:
> Jorgen Grahn wrote:
...
>> On my machines, there is One Correct Way of doing these things, and that's
>> to look in the MIME support/configuration files (~/.mailcap, and so on),
>> first for the user, then system-wide. Something there might tell you what
>> program should handle text/html content.
>
> Indeed. Thanks for reminding me about mailcap/metamail - I used them in

And thanks for mentioning the real name of that mechanism!

...
> import mailcap

I guess I shouldn't be surprised that there is a standard module
for that ... ;-)

...
> Sadly, when considering my KDE desktop's default browser, inquiring the
> application for HTML files yields Mozilla Firefox from my mailcap file.

Yes, but that's only because you haven't configured your mailcap, right?
Which might be a real problem -- most people don't touch their .mailcaps,
especially those who use KDE or Gnome.

Also, sometimes you want a GUI browser to open, and sometimes you want a
console-based one like lynx or w3m.  I guess most people who use mailcap do
so because they use console-based mail readers, and thus want the HTML stuff
appear inside the same terminal.  Another reason this might be unsuitable
for the OP.

So, while I called it "The One Correct Way" above, I admit it might not be a
very good way ;-)

/Jorgen

-- 
  // Jorgen Grahn   R'lyeh wgah'nagl fhtagn!
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Determining an operating system's default browser

2006-02-11 Thread Paul Boddie
Jorgen Grahn wrote:
>

[desktop module]

> Note that those do not, of course, work on all Unices.

Correct: they work only for the stated desktop environments.

> On my machines, there is One Correct Way of doing these things, and that's
> to look in the MIME support/configuration files (~/.mailcap, and so on),
> first for the user, then system-wide. Something there might tell you what
> program should handle text/html content.

Indeed. Thanks for reminding me about mailcap/metamail - I used them in
a project about ten years ago, and I suppose not having any
opportunities to use them in the intervening period probably pushed
them to the back of my mind.

> This mechanism is widespread under Unix, I think ... but I don't know if
> there is a general interface to it, or a Python interface.

Here's an example:

import mailcap
command, entry = mailcap.findmatch(mailcap.getcaps(), "text/html")

Here's another more comprehensive set of examples:

http://effbot.org/librarybook/mailcap.htm

Sadly, when considering my KDE desktop's default browser, inquiring the
application for HTML files yields Mozilla Firefox from my mailcap file.
What I've discovered is that the issue of an URL-opening application is
often quite separate from an appropriate application to open a file of
a given type. Perhaps I should call desktop.open something like
desktop.urlopen instead, since that name arguably describes the purpose
of the function more accurately.

Paul

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Determining an operating system's default browser

2006-02-11 Thread Jorgen Grahn
On 10 Feb 2006 03:51:01 -0800, Paul Boddie <[EMAIL PROTECTED]> wrote:
> John McMonagle wrote:
>> On Thu, 2006-02-09 at 17:53 -0600, Larry Bates wrote:
>> > You don't have to determine it.  Just os.startfile('page1.html')
>> > and let the OS figure it out.
>>
>> Works great for Windows - not available on Unix though.
>
> Take a look at the desktop module for similar functionality for KDE,
> GNOME and the Mac OS X desktop environment (as well as Windows, of
> course):

Note that those do not, of course, work on all Unices.

On my machines, there is One Correct Way of doing these things, and that's
to look in the MIME support/configuration files (~/.mailcap, and so on),
first for the user, then system-wide. Something there might tell you what
program should handle text/html content.

This mechanism is widespread under Unix, I think ... but I don't know if
there is a general interface to it, or a Python interface.

/Jorgen

-- 
  // Jorgen Grahn   R'lyeh wgah'nagl fhtagn!
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Determining an operating system's default browser

2006-02-10 Thread Sion Arrowsmith
John McMonagle  <[EMAIL PROTECTED]> wrote:
>Is there a python module which can determine an operating system's
>default web browser application.

http://docs.python.org/lib/module-webbrowser.html

-- 
\S -- [EMAIL PROTECTED] -- http://www.chaos.org.uk/~sion/
  ___  |  "Frankly I have no feelings towards penguins one way or the other"
  \X/  |-- Arthur C. Clarke
   her nu becomeþ se bera eadward ofdun hlæddre heafdes bæce bump bump bump
-- 
http://mail.python.org/mailman/listinfo/python-list

Re: Determining an operating system's default browser

2006-02-10 Thread Paul Boddie
John McMonagle wrote:
> On Thu, 2006-02-09 at 17:53 -0600, Larry Bates wrote:
> > You don't have to determine it.  Just os.startfile('page1.html')
> > and let the OS figure it out.
>
> Works great for Windows - not available on Unix though.

Take a look at the desktop module for similar functionality for KDE,
GNOME and the Mac OS X desktop environment (as well as Windows, of
course):

http://www.python.org/pypi/desktop

Paul

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Determining an operating system's default browser

2006-02-10 Thread Fuzzyman

John McMonagle wrote:
> Is there a python module which can determine an operating system's
> default web browser application.
>
> I would like to use it in the following context:  I have a GUI
> application where all the documentation is written as html pages.  I
> wish to have these html help pages open in the default browser when
> selected from the application's Help menu
>
> If python can determine the path to the default browser, I can then just
> spawn it.
>

The module webrowser module does this - and I use it for exactly this
purpose. :-)

Fuzzyman
http://www.voidspace.org.uk/python/index.shtml

> Regards,
>
> John McMonagle
>
>
>
>
> --
> This message has been scanned for viruses and
> dangerous content by MailScanner, and is
> believed to be clean.

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Determining an operating system's default browser

2006-02-10 Thread Juho Schultz
John McMonagle wrote:
> Is there a python module which can determine an operating system's
> default web browser application.
> 
> I would like to use it in the following context:  I have a GUI
> application where all the documentation is written as html pages.  I
> wish to have these html help pages open in the default browser when
> selected from the application's Help menu
> 
> If python can determine the path to the default browser, I can then just
> spawn it.
> 
> Regards,
> 
> John McMonagle
> 
> 
> 
I think the htmlview command is used for this purpose (displaying html 
documentation of applications) on many Linuxes. So you could try 
os.system('htmlview'). Given the variety of Unixes (and even Linuxes) 
out there this is not a general solution.

So I would try htmlview first. If it does not work, the program could 
ask the user for his favourite browser the 1st time he looks at docs, 
and save this to a configuration file.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Determining an operating system's default browser

2006-02-09 Thread [EMAIL PROTECTED]
Larry Bates wrote:
> You don't have to determine it.  Just os.startfile('page1.html')
> and let the OS figure it out.

Note that this only works on Windows.

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Determining an operating system's default browser

2006-02-09 Thread John McMonagle
On Thu, 2006-02-09 at 17:53 -0600, Larry Bates wrote:
> You don't have to determine it.  Just os.startfile('page1.html')
> and let the OS figure it out.

Works great for Windows - not available on Unix though.



-- 
This message has been scanned for viruses and
dangerous content by MailScanner, and is
believed to be clean.

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Determining an operating system's default browser

2006-02-09 Thread Larry Bates
You don't have to determine it.  Just os.startfile('page1.html')
and let the OS figure it out.

-Larry Bates


John McMonagle wrote:
> Is there a python module which can determine an operating system's
> default web browser application.
> 
> I would like to use it in the following context:  I have a GUI
> application where all the documentation is written as html pages.  I
> wish to have these html help pages open in the default browser when
> selected from the application's Help menu
> 
> If python can determine the path to the default browser, I can then just
> spawn it.
> 
> Regards,
> 
> John McMonagle
> 
> 
> 
> 
-- 
http://mail.python.org/mailman/listinfo/python-list


Determining an operating system's default browser

2006-02-09 Thread John McMonagle
Is there a python module which can determine an operating system's
default web browser application.

I would like to use it in the following context:  I have a GUI
application where all the documentation is written as html pages.  I
wish to have these html help pages open in the default browser when
selected from the application's Help menu

If python can determine the path to the default browser, I can then just
spawn it.

Regards,

John McMonagle




-- 
This message has been scanned for viruses and
dangerous content by MailScanner, and is
believed to be clean.

-- 
http://mail.python.org/mailman/listinfo/python-list