Velocity Reviews

Velocity Reviews (http://www.velocityreviews.com/forums/index.php)
-   Python (http://www.velocityreviews.com/forums/f43-python.html)
-   -   webbrowser.open("./documentation/help.html")-- No Go in Windows (http://www.velocityreviews.com/forums/t958004-webbrowser-open-documentation-help-html-no-go-in-windows.html)

llanitedave 02-24-2013 09:17 AM

webbrowser.open("./documentation/help.html")-- No Go in Windows
 
I created an html help page for my Python 2.7.3 application and put it in adocumentation folder. I used webbrowser.open() to fetch the page.

On linux -- KDE specifically, the command opens the local file on my default browser with no issues. However, on Windows 7, it opens Internet Explorer, which doesn't even search the local folder, but goes straight to the weband does a Google search, returning nothing but useless noise.

My default browser on Windows is Chrome, so my intention is getting undermined right from the start.

How do I get a local html file to open properly from Python in Windows?

Chris Rebert 02-24-2013 09:24 AM

Re: webbrowser.open("./documentation/help.html")-- No Go in Windows
 
On Feb 24, 2013 1:21 AM, "llanitedave" <llanitedave@veawb.coop> wrote:
>
> I created an html help page for my Python 2.7.3 application and put it in

a documentation folder. I used webbrowser.open() to fetch the page.
>
> On linux -- KDE specifically, the command opens the local file on my

default browser with no issues. However, on Windows 7, it opens Internet
Explorer, which doesn't even search the local folder, but goes straight to
the web and does a Google search, returning nothing but useless noise.
>
> My default browser on Windows is Chrome, so my intention is getting

undermined right from the start.
>
> How do I get a local html file to open properly from Python in Windows?


Please provide the exact code snippet that you're using.

Cheers,
Chris


Demian Brecht 02-24-2013 09:25 AM

Re: webbrowser.open("./documentation/help.html")-- No Go in Windows
 
Rather than using a relative path, try using
webbrowser.open('{}/documentation/help.html'.format(os.path.dirname(__file__))).

On Sun, Feb 24, 2013 at 1:17 AM, llanitedave <llanitedave@veawb.coop> wrote:
> I created an html help page for my Python 2.7.3 application and put it ina documentation folder. I used webbrowser.open() to fetch the page.
>
> On linux -- KDE specifically, the command opens the local file on my default browser with no issues. However, on Windows 7, it opens Internet Explorer, which doesn't even search the local folder, but goes straight to the web and does a Google search, returning nothing but useless noise.
>
> My default browser on Windows is Chrome, so my intention is getting undermined right from the start.
>
> How do I get a local html file to open properly from Python in Windows?
> --
> http://mail.python.org/mailman/listinfo/python-list




--
Demian Brecht
http://demianbrecht.github.com

Chris Rebert 02-24-2013 09:35 AM

Re: webbrowser.open("./documentation/help.html")-- No Go in Windows
 
On Feb 24, 2013 1:21 AM, "llanitedave" <llanitedave@veawb.coop> wrote:
>
> I created an html help page for my Python 2.7.3 application and put it in

a documentation folder. I used webbrowser.open() to fetch the page.
>
> On linux -- KDE specifically, the command opens the local file on my

default browser with no issues. However, on Windows 7, it opens Internet
Explorer, which doesn't even search the local folder, but goes straight to
the web and does a Google search, returning nothing but useless noise.
>
> My default browser on Windows is Chrome, so my intention is getting

undermined right from the start.
>
> How do I get a local html file to open properly from Python in Windows?


Sounds like this might be your problem:
http://bugs.python.org/issue8936

The fix would seem to be ensuring that the URL you pass includes the scheme
(in your case, "file:").

Cheers,
Chris


llanitedave 02-24-2013 08:28 PM

Re: webbrowser.open("./documentation/help.html")-- No Go in Windows
 
On Sunday, February 24, 2013 1:35:31 AM UTC-8, Chris Rebert wrote:
> On Feb 24, 2013 1:21 AM, "llanitedave" <llani...@veawb.coop> wrote:
>
> >

>
> > I created an html help page for my Python 2.7.3 application and put it in a documentation folder. *I used webbrowser.open() to fetch the page.

>
> >

>
> > On linux -- KDE specifically, the command opens the local file on my default browser with no issues. *However, on Windows 7, it opens Internet Explorer, which doesn't even search the local folder, but goes straight to the web and does a Google search, returning nothing but useless noise.

>
>
> >

>
> > My default browser on Windows is Chrome, so my intention is getting undermined right from the start.

>
> >

>
> > How do I get a local html file to open properly from Python in Windows?

>
> Sounds like this might be your problem:
>
> http://bugs.python.org/issue8936
>
> The fix would seem to be ensuring that the URL you pass includes the scheme (in your case, "file:").
>
> Cheers,
>
> Chris


Holy Toledo! That's a two-year-old bug spanning two versions of the language!

BTW, Chris, the snippet I showed in the title essentially WAS the exact code. It's a method with that single line called from a wxPython Help menu. I can't really put an absolute pathname into the argument, because the application is going to be distributed to a variety of computers at my workplace, and there's no assurance that it will go into (or remain in)a particularfolder.

I was trying to avoid using the wx.html.HtmlWindow feature of wxPython, because it doesn't handle CSS and styles. My help page is the portal to a multi-page users guide with a style sheet to render all the content consistently.

Plus, I couldn't get the wx.html.HtmlWindow to open relative paths either -- it gave me "URL Malformed" messages even in KDE, when webbrowser.open("filepath") was working for the exact same path. But that's something to takeup on the wxPython list, I guess.

This to me illustrates the downside of the Python philosophy of "There should be only one obvious way to do things". If that one obvious way has a fatal bug, you're pretty much SOL.

llanitedave 02-24-2013 08:28 PM

Re: webbrowser.open("./documentation/help.html")-- No Go in Windows
 
On Sunday, February 24, 2013 1:35:31 AM UTC-8, Chris Rebert wrote:
> On Feb 24, 2013 1:21 AM, "llanitedave" <llani...@veawb.coop> wrote:
>
> >

>
> > I created an html help page for my Python 2.7.3 application and put it in a documentation folder. *I used webbrowser.open() to fetch the page.

>
> >

>
> > On linux -- KDE specifically, the command opens the local file on my default browser with no issues. *However, on Windows 7, it opens Internet Explorer, which doesn't even search the local folder, but goes straight to the web and does a Google search, returning nothing but useless noise.

>
>
> >

>
> > My default browser on Windows is Chrome, so my intention is getting undermined right from the start.

>
> >

>
> > How do I get a local html file to open properly from Python in Windows?

>
> Sounds like this might be your problem:
>
> http://bugs.python.org/issue8936
>
> The fix would seem to be ensuring that the URL you pass includes the scheme (in your case, "file:").
>
> Cheers,
>
> Chris


Holy Toledo! That's a two-year-old bug spanning two versions of the language!

BTW, Chris, the snippet I showed in the title essentially WAS the exact code. It's a method with that single line called from a wxPython Help menu. I can't really put an absolute pathname into the argument, because the application is going to be distributed to a variety of computers at my workplace, and there's no assurance that it will go into (or remain in)a particularfolder.

I was trying to avoid using the wx.html.HtmlWindow feature of wxPython, because it doesn't handle CSS and styles. My help page is the portal to a multi-page users guide with a style sheet to render all the content consistently.

Plus, I couldn't get the wx.html.HtmlWindow to open relative paths either -- it gave me "URL Malformed" messages even in KDE, when webbrowser.open("filepath") was working for the exact same path. But that's something to takeup on the wxPython list, I guess.

This to me illustrates the downside of the Python philosophy of "There should be only one obvious way to do things". If that one obvious way has a fatal bug, you're pretty much SOL.

Chris Rebert 02-24-2013 08:48 PM

Re: webbrowser.open("./documentation/help.html")-- No Go in Windows
 
On Sun, Feb 24, 2013 at 12:28 PM, llanitedave <llanitedave@veawb.coop> wrote:
> On Sunday, February 24, 2013 1:35:31 AM UTC-8, Chris Rebert wrote:
>> On Feb 24, 2013 1:21 AM, "llanitedave" <llani...@veawb.coop> wrote:
>> > I created an html help page for my Python 2.7.3 application and put itin a documentation folder. I used webbrowser.open() to fetch the page.
>> > On linux -- KDE specifically, the command opens the local file on my default browser with no issues. However, on Windows 7, it opens Internet Explorer, which doesn't even search the local folder, but goes straight to the web and does a Google search, returning nothing but useless noise.
>> > My default browser on Windows is Chrome, so my intention is getting undermined right from the start.
>> > How do I get a local html file to open properly from Python in Windows?

>>
>> Sounds like this might be your problem:
>> http://bugs.python.org/issue8936
>>
>> The fix would seem to be ensuring that the URL you pass includes the scheme (in your case, "file:").

>
> Holy Toledo! That's a two-year-old bug spanning two versions of the language!
>
> BTW, Chris, the snippet I showed in the title essentially WAS the exact code.


Sorry, my bad. This is why I dislike messages that put critical info
*only* in the subject line; I tend not to reread the subject line once
I've opened the message.

> It's a method with that single line called from a wxPython Help menu. Ican't really put an absolute pathname into the argument, because the application is going to be distributed to a variety of computers at my workplace, and there's no assurance that it will go into (or remain in)a particular folder.


As Demian demonstrated, you can simply compute the absolute path from
the relative path at runtime; although I would probably toss an
abspath() call in for good measure
(http://docs.python.org/2/library/os....s.path.abspath ).

> This to me illustrates the downside of the Python philosophy of "There should be only one obvious way to do things". If that one obvious way has a fatal bug, you're pretty much SOL.


On the other hand, you don't have to investigate which of N APIs is
the "fixed"/"correct" one (Which PHP MySQL function is safe from SQL
injection again?), and you only have wait for 1 fix instead of N. But
yes, some of Python's included batteries are due for some recharging.

Cheers,
Chris

Mark Lawrence 02-24-2013 08:50 PM

Re: webbrowser.open("./documentation/help.html")-- No Go in Windows
 
On 24/02/2013 20:28, llanitedave wrote:
> On Sunday, February 24, 2013 1:35:31 AM UTC-8, Chris Rebert wrote:
>> On Feb 24, 2013 1:21 AM, "llanitedave" <llani...@veawb.coop> wrote:
>>
>>>

>>
>>> I created an html help page for my Python 2.7.3 application and put it in a documentation folder. I used webbrowser.open() to fetch the page.

>>
>>>

>>
>>> On linux -- KDE specifically, the command opens the local file on my default browser with no issues. However, on Windows 7, it opens Internet Explorer, which doesn't even search the local folder, but goes straight to the web and does a Google search, returning nothing but useless noise.

>>
>>
>>>

>>
>>> My default browser on Windows is Chrome, so my intention is getting undermined right from the start.

>>
>>>

>>
>>> How do I get a local html file to open properly from Python in Windows?

>>
>> Sounds like this might be your problem:
>>
>> http://bugs.python.org/issue8936
>>
>> The fix would seem to be ensuring that the URL you pass includes the scheme (in your case, "file:").
>>
>> Cheers,
>>
>> Chris

>
> Holy Toledo! That's a two-year-old bug spanning two versions of the language!


Only two years is nothing. Pay your money, take your choice :)

> This to me illustrates the downside of the Python philosophy of "There should be only one obvious way to do things". If that one obvious way has a fatal bug, you're pretty much SOL.


Misquoted as always. I guess that some day someone will quote it correctly.

--
Cheers.

Mark Lawrence


llanitedave 02-24-2013 09:04 PM

Re: webbrowser.open("./documentation/help.html")-- No Go in Windows
 
On Sunday, February 24, 2013 12:48:40 PM UTC-8, Chris Rebert wrote:
> On Sun, Feb 24, 2013 at 12:28 PM, llanitedave <llanitedave@veawb.coop> wrote:
>
> > On Sunday, February 24, 2013 1:35:31 AM UTC-8, Chris Rebert wrote:

>
> >> On Feb 24, 2013 1:21 AM, "llanitedave" <llani...@veawb.coop> wrote:

>
> >> > I created an html help page for my Python 2.7.3 application and put it in a documentation folder. I used webbrowser.open() to fetch the page.

>
> >> > On linux -- KDE specifically, the command opens the local file on mydefault browser with no issues. However, on Windows 7, it opens Internet Explorer, which doesn't even search the local folder, but goes straight to the web and does a Google search, returning nothing but useless noise.

>
> >> > My default browser on Windows is Chrome, so my intention is getting undermined right from the start.

>
> >> > How do I get a local html file to open properly from Python in Windows?

>
> >>

>
> >> Sounds like this might be your problem:

>
> >> http://bugs.python.org/issue8936

>
> >>

>
> >> The fix would seem to be ensuring that the URL you pass includes the scheme (in your case, "file:").

>
> >

>
> > Holy Toledo! That's a two-year-old bug spanning two versions of the language!

>
> >

>
> > BTW, Chris, the snippet I showed in the title essentially WAS the exactcode.

>
>
>
> Sorry, my bad. This is why I dislike messages that put critical info
>
> *only* in the subject line; I tend not to reread the subject line once
>
> I've opened the message.
>


Nah, my bad. I didn't realize that the title was the only place I'd put the actual command. I don't like it when other people do that either.

>
>
> > It's a method with that single line called from a wxPython Help menu. I can't really put an absolute pathname into the argument, because the application is going to be distributed to a variety of computers at my workplace, and there's no assurance that it will go into (or remain in)a particular folder.

>
>
>
> As Demian demonstrated, you can simply compute the absolute path from
>
> the relative path at runtime; although I would probably toss an
>
> abspath() call in for good measure
>
> (http://docs.python.org/2/library/os....s.path.abspath ).
>
>


OK, I'm going to have to study that one a bit. It looks like a new conceptfor my feeble brain.

>
> > This to me illustrates the downside of the Python philosophy of "There should be only one obvious way to do things". If that one obvious way has a fatal bug, you're pretty much SOL.

>
>
>
> On the other hand, you don't have to investigate which of N APIs is
>
> the "fixed"/"correct" one (Which PHP MySQL function is safe from SQL
>
> injection again?), and you only have wait for 1 fix instead of N. But
>
> yes, some of Python's included batteries are due for some recharging.
>
>
>
> Cheers,
>
> Chris


You're right. It's one thing to have a persistent bug, it's another thing to offer the function in the documentation as if the bug doesn't exist.

The bug report from October 2010 indicated that someone was working on a fix at that time. The fact that it's still not fixed implies that it might be something that's really hard to pin down. In a case like that, it's probably better to simply withdraw the feature, or tag it as "Non-windows only"

llanitedave 02-24-2013 09:04 PM

Re: webbrowser.open("./documentation/help.html")-- No Go in Windows
 
On Sunday, February 24, 2013 12:48:40 PM UTC-8, Chris Rebert wrote:
> On Sun, Feb 24, 2013 at 12:28 PM, llanitedave <llanitedave@veawb.coop> wrote:
>
> > On Sunday, February 24, 2013 1:35:31 AM UTC-8, Chris Rebert wrote:

>
> >> On Feb 24, 2013 1:21 AM, "llanitedave" <llani...@veawb.coop> wrote:

>
> >> > I created an html help page for my Python 2.7.3 application and put it in a documentation folder. I used webbrowser.open() to fetch the page.

>
> >> > On linux -- KDE specifically, the command opens the local file on mydefault browser with no issues. However, on Windows 7, it opens Internet Explorer, which doesn't even search the local folder, but goes straight to the web and does a Google search, returning nothing but useless noise.

>
> >> > My default browser on Windows is Chrome, so my intention is getting undermined right from the start.

>
> >> > How do I get a local html file to open properly from Python in Windows?

>
> >>

>
> >> Sounds like this might be your problem:

>
> >> http://bugs.python.org/issue8936

>
> >>

>
> >> The fix would seem to be ensuring that the URL you pass includes the scheme (in your case, "file:").

>
> >

>
> > Holy Toledo! That's a two-year-old bug spanning two versions of the language!

>
> >

>
> > BTW, Chris, the snippet I showed in the title essentially WAS the exactcode.

>
>
>
> Sorry, my bad. This is why I dislike messages that put critical info
>
> *only* in the subject line; I tend not to reread the subject line once
>
> I've opened the message.
>


Nah, my bad. I didn't realize that the title was the only place I'd put the actual command. I don't like it when other people do that either.

>
>
> > It's a method with that single line called from a wxPython Help menu. I can't really put an absolute pathname into the argument, because the application is going to be distributed to a variety of computers at my workplace, and there's no assurance that it will go into (or remain in)a particular folder.

>
>
>
> As Demian demonstrated, you can simply compute the absolute path from
>
> the relative path at runtime; although I would probably toss an
>
> abspath() call in for good measure
>
> (http://docs.python.org/2/library/os....s.path.abspath ).
>
>


OK, I'm going to have to study that one a bit. It looks like a new conceptfor my feeble brain.

>
> > This to me illustrates the downside of the Python philosophy of "There should be only one obvious way to do things". If that one obvious way has a fatal bug, you're pretty much SOL.

>
>
>
> On the other hand, you don't have to investigate which of N APIs is
>
> the "fixed"/"correct" one (Which PHP MySQL function is safe from SQL
>
> injection again?), and you only have wait for 1 fix instead of N. But
>
> yes, some of Python's included batteries are due for some recharging.
>
>
>
> Cheers,
>
> Chris


You're right. It's one thing to have a persistent bug, it's another thing to offer the function in the documentation as if the bug doesn't exist.

The bug report from October 2010 indicated that someone was working on a fix at that time. The fact that it's still not fixed implies that it might be something that's really hard to pin down. In a case like that, it's probably better to simply withdraw the feature, or tag it as "Non-windows only"


All times are GMT. The time now is 07:30 AM.

Powered by vBulletin®. Copyright ©2000 - 2014, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.