Brandon Milam added the comment:

In order to fix the issue I added on to the WindowsDefault class so that it is 
the main browser class for windows platforms as opposed to being a default when 
no other browser is given. I gave the class an init where it specifies specific 
flags for firefox, chrome, and internet explorer (from what I could find there 
aren't really new window or new tab flags for internet explorer). If the flags 
for other browsers are known they should be easy to add to this section.

        def __init__(self,browser = "windows-default"):
            # Grab the different flags for the different browser types
            browser.lower()
            self.browsername = browser
            # If get() is used without arguments browser will be passed None
            if browser == "windows_default" or browser == None:
                self.cmd = "start"
            elif browser == 'iexplore' or browser == 'internet explorer':
                self.cmd = "start iexplore"
                self.newwindow = ""
                self.newtab = ""
            elif browser == "chrome":
                self.cmd = "start chrome.exe"
                self.newwindow = "-new-window"
                self.newtab = "-new-tab"
            elif browser == "firefox":
                self.cmd = "start firefox.exe"
                self.newwindow = "-new-window"
                self.newtab = "-new-tab"
            else:
                raise Error('The browser you entered (%s) is not currently 
supported on windows' % browser)

In the open method of the WindowsDefault class I changed how the browser is 
opened by building a command from the flags and the cmd for the specific 
browser and used subprocess,call.

            # Format the command for optional arguments and add the url
            if new == 1:
                self.cmd += " " + self.newwindow
            elif new == 2:
                self.cmd += " " + self.newtab
            self.cmd += " " + url

            subprocess.call(self.cmd,shell = True)

This allows the user to input different new arguments to open a new window or 
new tab like the documentation says they should be able to do. I added a little 
bit to the beginning of the get function so that it passes its argument to the 
WindowsDefault class and returns that object on Windows systems.

    # Let the windows default class handle different browsers on windows
    if sys.platform[:3] == "win":
        return WindowsDefault(using)

This adds some of the desired compatibility but does not completely address the 
module's issues. I did not see a way to open a web page in a currently open 
page on any of the browsers, just new windows and new tabs (when no flags are 
passed the browsers default to one of these two options). Also the 
_isexecutable function's attempt at windows compatibility is still not working 
because I was unsure of how to use just a string of a browser name like 
'chrome' to determine if a file is on a system. This leaves _tryorder not 
properly containing the browsers on the system. This leaves the module's open, 
open_new and open_new_tab not properly working either just the WindowsDefault 
open method.
Any feed back and direction from here is most welcome.

----------
nosy: +jbmilam
Added file: http://bugs.python.org/file36110/webbrowserdebug.py

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue8232>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to