<reponame>ThoughtfulDev/Eel
'''
Some edits from: https://github.com/Mohamad1994HD/Eel/tree/master/eel
Thanks Mohamad!
'''
import webbrowser as wbr, subprocess as sps
from .chrome import Chrome

def open(start_pages, options):
    base_url = 'http://%s:%d/' % (options['host'], options['port'])
    start_urls = [base_url + page for page in start_pages]

    if options['mode'] in ['chrome', 'chrome-app']:
        chrome_path = Chrome().instance 
  
        if chrome_path != None:
            if options['mode'] == 'chrome-app':
                for url in start_urls:
                    sps.Popen([chrome_path, '--app=%s' % url] + options['chromeFlags'], stdout=sps.PIPE, stderr=sps.PIPE)
            else:
                args = options['chromeFlags'] + start_urls
                sps.Popen([chrome_path, '--new-window'] + args, stdout=sps.PIPE, stderr=sps.PIPE)
        else:
            #fallback for default browser
            for url in start_urls:
                wbr.open(url)
    elif options['mode'] in [None, False]:
        pass # Don't open a browser
    else:
        # Use system default browser
        for url in start_urls:
            wbr.open(url)
'''
Some edits from: https://github.com/Mohamad1994HD/Eel/tree/master/eel
Thanks Mohamad!
'''
import webbrowser as wbr, subprocess as sps
from .chrome import Chrome

def open(start_pages, options):
    base_url = 'http://%s:%d/' % (options['host'], options['port'])
    start_urls = [base_url + page for page in start_pages]

    if options['mode'] in ['chrome', 'chrome-app']:
        chrome_path = Chrome().instance 
  
        if chrome_path != None:
            if options['mode'] == 'chrome-app':
                for url in start_urls:
                    sps.Popen([chrome_path, '--app=%s' % url] + options['chromeFlags'], stdout=sps.PIPE, stderr=sps.PIPE)
            else:
                args = options['chromeFlags'] + start_urls
                sps.Popen([chrome_path, '--new-window'] + args, stdout=sps.PIPE, stderr=sps.PIPE)
        else:
            #fallback for default browser
            for url in start_urls:
                wbr.open(url)
    elif options['mode'] in [None, False]:
        pass # Don't open a browser
    else:
        # Use system default browser
        for url in start_urls:
            wbr.open(url)
Some edits from: https://github.com/Mohamad1994HD/Eel/tree/master/eel Thanks Mohamad! #fallback for default browser # Don't open a browser # Use system default browser