示例#1
0
def start_web_browser(initial_url, exit_handler=None):
    """
    Create a new instance of a web browser.
    @param initial_url: Optional initial URL to be displayed.
    """
    global _initial_url
    _initial_url = initial_url
    local_server = get_local_server()
    proxy = 'localhost:%d' % local_server.server_port
    start_url = 'http://freevo/wbinitial.html'
    browser_process = Process([config.CHROME_PATH, '--app='+start_url, '--proxy-server=' + proxy])
    if exit_handler:
        browser_process.signals['exited'].connect(exit_handler)
    browser_process.start()
    return browser_process
示例#2
0
def start_web_browser(initial_url, exit_handler=None):
    """
    Create a new instance of a web browser.
    @param initial_url: Optional initial URL to be displayed.
    """
    global _initial_url
    _initial_url = initial_url
    local_server = get_local_server()
    proxy = 'localhost:%d' % local_server.server_port
    start_url = 'http://freevo/wbinitial.html'
    browser_process = Process(
        [config.CHROME_PATH, '--app=' + start_url, '--proxy-server=' + proxy])
    if exit_handler:
        browser_process.signals['exited'].connect(exit_handler)
    browser_process.start()
    return browser_process
示例#3
0
        self.name = name


    def __getattr__(self, item):
        return JSObject(self.ipc, self, item)


    def __call__(self, *args, **kwargs):
        n = self.name
        p = self.parent
        while p is not None:
            n = p.name + '.' + n
            p = p.parent
        return self.ipc('%s(%s)' % (n, json.dumps(args)[1:-1]))


def _get_initial_HTML(request):
    f = open(os.path.join(HTML_DIR, 'wbinitial.html'))
    initial_html = f.read()
    f.close()
    html =  initial_html % (config.CONF.width, config.CONF.height, config.CONF.x, config.CONF.y, _initial_url)
    request.send_response(200)
    request.send_header('content-type', 'text/html')
    request.send_header('content-length', str(len(html)))
    request.end_headers()
    request.wfile.write(html)


get_local_server().register_handler('^http://freevo/wbinitial.html$', _get_initial_HTML)

ipc = WebIPC(get_local_server())
示例#4
0
        self.name = name

    def __getattr__(self, item):
        return JSObject(self.ipc, self, item)

    def __call__(self, *args, **kwargs):
        n = self.name
        p = self.parent
        while p is not None:
            n = p.name + '.' + n
            p = p.parent
        return self.ipc('%s(%s)' % (n, json.dumps(args)[1:-1]))


def _get_initial_HTML(request):
    f = open(os.path.join(HTML_DIR, 'wbinitial.html'))
    initial_html = f.read()
    f.close()
    html = initial_html % (config.CONF.width, config.CONF.height,
                           config.CONF.x, config.CONF.y, _initial_url)
    request.send_response(200)
    request.send_header('content-type', 'text/html')
    request.send_header('content-length', str(len(html)))
    request.end_headers()
    request.wfile.write(html)


get_local_server().register_handler('^http://freevo/wbinitial.html$',
                                    _get_initial_HTML)

ipc = WebIPC(get_local_server())