def __init__(self, parent, config=None, credential_file=None, cookie_persistence=False, log_level=logging.INFO):
        super(AuthWidget, self).__init__(parent)

        self.parent = parent
        self.config = None
        self.config_file = DEFAULT_CONFIG_FILE
        self.credential = DEFAULT_CREDENTIAL
        self.credential_file = None
        self.cookie_file = None
        self.cookie_jar = None
        self.auth_url = None
        self.authn_session = None
        self.authn_session_page = None
        self.authn_cookie_name = None
        self.authn_expires = time.time()
        self._success_callback = None
        self._failure_callback = None
        self._session = requests.session()
        self.token = None
        self.default_profile = QWebEngineProfile("deriva-auth", self)
        self.private_profile = QWebEngineProfile(self)

        logging.getLogger().setLevel(log_level)
        info = "%s v%s [Python: %s (PyQt: %s), %s]" % (
            self.__class__.__name__, get_installed_version(VERSION),
            platform.python_version(), PYQT_VERSION_STR, platform.platform(aliased=True))
        logging.info("Initializing authorization provider: %s" % info)
        self.cookie_persistence = cookie_persistence
        self._timer = QTimer(self)
        self._timer.timeout.connect(self._onTimerFired)
        self.configure(config, credential_file)
Esempio n. 2
0
    def __init__(self, *args, **kwargs):
        super(Window, self).__init__(*args, **kwargs)

        # 用户1
        self.webView1 = QWebEngineView(self)
        profile1 = QWebEngineProfile('storage1', self.webView1)
        profile1.setPersistentStoragePath('Tmp/Storage1')
        print(profile1.cookieStore())
        # 如果要清除cookie
        # cookieStore = profile1.cookieStore()
        # cookieStore.deleteAllCookies()
        # cookieStore.deleteSessionCookies()
        page1 = QWebEnginePage(profile1, self.webView1)
        self.webView1.setPage(page1)
        self.addTab(self.webView1, '用户1')

        # 用户2
        self.webView2 = QWebEngineView(self)
        profile2 = QWebEngineProfile('storage2', self.webView2)
        profile2.setPersistentStoragePath('Tmp/Storage2')
        print(profile2.cookieStore())
        page2 = QWebEnginePage(profile2, self.webView2)
        self.webView2.setPage(page2)
        self.addTab(self.webView2, '用户2')

        self.webView1.load(QUrl('https://v.qq.com'))
        self.webView2.load(QUrl('https://v.qq.com'))
Esempio n. 3
0
def convert(args):
    profile = QWebEngineProfile()
    page = HeadlessPage(profile)

    settings = page.settings()
    settings.setAttribute(settings.JavascriptCanOpenWindows, False)
    settings.setAttribute(settings.WebGLEnabled, False)
    settings.setAttribute(settings.AutoLoadIconsForPage, False)
    settings.setAttribute(settings.ShowScrollBars, False)

    qurl = QUrl(args['url'])
    req = QWebEngineHttpRequest(qurl)

    for name, value in args.get('headers', ()):
        req.setHeader(name.encode('utf-8'), value.encode('utf-8'))

    store = page.profile().cookieStore()
    for name, value in args.get('cookies', ()):
        cookie = QNetworkCookie(name.encode('utf-8'), value.encode('utf-8'))
        cookie.setDomain(qurl.host())
        store.setCookie(cookie)

    with prepare_loop(page.loadFinished):
        page.load(req)

    for js in args.get('run_script', ()):
        with prepare_loop() as loop:
            page.runJavaScript(js, lambda _: loop.quit())

    if args['dest'] != '-':
        with prepare_loop(page.pdfPrintingFinished):
            page.printToPdf(os.path.abspath(args['dest']))
    else:
        sys.stdout.buffer.write(page.printToPdfAndReturn())
Esempio n. 4
0
    def __init__(self, *args, **kwargs):
        # Strip out arguments we handle that are different from QMainWindow:
        if 'width' in kwargs:
            self.width = kwargs['width']
            del kwargs['width']
        else:
            self.width = 1024
        if 'height' in kwargs:
            self.height = kwargs['height']
            del kwargs['height']
        else:
            # Short enough to fit in XGA, 768 height:
            self.height = 735

        # Then run the default constructor.
        super(BrowserWindow, self).__init__(*args, **kwargs)

        self.browserviews = []

        self.profile = QWebEngineProfile()
        # print("Profile initially off the record?",
        #       self.profile.isOffTheRecord())
        # self.interceptor = BrowserRequestInterceptor()
        # self.profile.setRequestInterceptor(self.interceptor)

        self.init_tab_name_len = 40

        self.init_chrome()

        # Resize to fit on an XGA screen, allowing for window chrome.
        # XXX Should check the screen size and see if it can be bigger.
        self.resize(self.width, self.height)
Esempio n. 5
0
def create_profile():
    ans = getattr(create_profile, 'ans', None)
    if ans is None:
        ans = QWebEngineProfile(QApplication.instance())
        ua = 'calibre-editor-preview ' + __version__
        ans.setHttpUserAgent(ua)
        if is_running_from_develop:
            from calibre.utils.rapydscript import compile_editor
            compile_editor()
        js = P('editor.js', data=True, allow_user_override=False)
        cparser = P('csscolorparser.js', data=True, allow_user_override=False)
        dark_mode_css = P('dark_mode.css',
                          data=True,
                          allow_user_override=False).decode('utf-8')

        insert_scripts(
            ans, create_script('csscolorparser.js', cparser),
            create_script('editor.js', js),
            create_script('dark-mode.js',
                          '''
            (function() {
                var settings = JSON.parse(navigator.userAgent.split('|')[1]);
                var dark_css = CSS;

                function apply_body_colors(event) {
                    if (document.documentElement) {
                        if (settings.bg) document.documentElement.style.backgroundColor = settings.bg;
                        if (settings.fg) document.documentElement.style.color = settings.fg;
                    }
                    if (document.body) {
                        if (settings.bg) document.body.style.backgroundColor = settings.bg;
                        if (settings.fg) document.body.style.color = settings.fg;
                    }
                }

                function apply_css() {
                    var css = '';
                    if (settings.link) css += 'html > body :link, html > body :link * { color: ' + settings.link + ' !important; }';
                    if (settings.is_dark_theme) { css += dark_css; }
                    var style = document.createElement('style');
                    style.textContent = css;
                    document.documentElement.appendChild(style);
                    apply_body_colors();
                }

                apply_body_colors();
                document.addEventListener("DOMContentLoaded", apply_css);
            })();
            '''.replace('CSS', json.dumps(dark_mode_css), 1),
                          injection_point=QWebEngineScript.InjectionPoint.
                          DocumentCreation))
        url_handler = UrlSchemeHandler(ans)
        ans.installUrlSchemeHandler(QByteArray(FAKE_PROTOCOL.encode('ascii')),
                                    url_handler)
        s = ans.settings()
        s.setDefaultTextEncoding('utf-8')
        s.setAttribute(s.FullScreenSupportEnabled, False)
        s.setAttribute(s.LinksIncludedInFocusChain, False)
        create_profile.ans = ans
    return ans
Esempio n. 6
0
def create_profile():
    ans = getattr(create_profile, 'ans', None)
    if ans is None:
        ans = QWebEngineProfile(QApplication.instance())
        ua = 'calibre-editor-preview ' + __version__
        ans.setHttpUserAgent(ua)
        if is_running_from_develop:
            from calibre.utils.rapydscript import compile_editor
            compile_editor()
        js = P('editor.js', data=True, allow_user_override=False)
        cparser = P('csscolorparser.js', data=True, allow_user_override=False)

        insert_scripts(
            ans,
            create_script('csscolorparser.js', cparser),
            create_script('editor.js', js),
        )
        url_handler = UrlSchemeHandler(ans)
        ans.installUrlSchemeHandler(QByteArray(FAKE_PROTOCOL.encode('ascii')),
                                    url_handler)
        s = ans.settings()
        s.setDefaultTextEncoding('utf-8')
        s.setAttribute(s.FullScreenSupportEnabled, False)
        s.setAttribute(s.LinksIncludedInFocusChain, False)
        create_profile.ans = ans
    return ans
Esempio n. 7
0
 def __init__(self, parent):
     super(BrowserTab, self).__init__(parent=parent)
     self.profile = QWebEngineProfile("storage", self)
     self.webpage = QWebEnginePage(self.profile, self)
     self.setPage(self.webpage)
     self.load(QUrl("https://www.epicgames.com/store/"))
     self.show()
Esempio n. 8
0
def create_profile():
    ans = getattr(create_profile, 'ans', None)
    if ans is None:
        ans = QWebEngineProfile(QApplication.instance())
        osname = 'windows' if iswindows else ('macos' if ismacos else 'linux')
        # DO NOT change the user agent as it is used to workaround
        # Qt bugs see workaround_qt_bug() in ajax.pyj
        ua = 'calibre-viewer {} {}'.format(__version__, osname)
        ans.setHttpUserAgent(ua)
        if is_running_from_develop:
            from calibre.utils.rapydscript import compile_viewer
            prints('Compiling viewer code...')
            compile_viewer()
        js = P('viewer.js', data=True, allow_user_override=False)
        translations_json = get_translations_data() or b'null'
        js = js.replace(b'__TRANSLATIONS_DATA__', translations_json, 1)
        if in_develop_mode:
            js = js.replace(b'__IN_DEVELOP_MODE__', b'1')
        insert_scripts(ans, create_script('viewer.js', js))
        url_handler = UrlSchemeHandler(ans)
        ans.installUrlSchemeHandler(QByteArray(FAKE_PROTOCOL.encode('ascii')), url_handler)
        s = ans.settings()
        s.setDefaultTextEncoding('utf-8')
        s.setAttribute(QWebEngineSettings.WebAttribute.LinksIncludedInFocusChain, False)
        create_profile.ans = ans
    return ans
Esempio n. 9
0
def _chromium_version():
    """Get the Chromium version for QtWebEngine.

    This can also be checked by looking at this file with the right Qt tag:
    https://github.com/qt/qtwebengine/blob/dev/tools/scripts/version_resolver.py#L41

    Quick reference:
    Qt 5.7:  Chromium 49
    Qt 5.8:  Chromium 53
    Qt 5.9:  Chromium 56
    Qt 5.10: Chromium 61
    Qt 5.11: Chromium 65
    Qt 5.12: Chromium 69 (?)

    Also see https://www.chromium.org/developers/calendar
    """
    if QWebEngineProfile is None:
        # This should never happen
        return 'unavailable'
    profile = QWebEngineProfile()
    ua = profile.httpUserAgent()
    match = re.search(r' Chrome/([^ ]*) ', ua)
    if not match:
        log.misc.error("Could not get Chromium version from: {}".format(ua))
        return 'unknown'
    return match.group(1)
Esempio n. 10
0
def _chromium_version():
    """Get the Chromium version for QtWebEngine.
    This can also be checked by looking at this file with the right Qt tag:
    http://code.qt.io/cgit/qt/qtwebengine.git/tree/tools/scripts/version_resolver.py#n41
    Quick reference:
    Qt 5.7:  Chromium 49
             49.0.2623.111 (2016-03-31)
             5.7.1: Security fixes up to 54.0.2840.87 (2016-11-01)
    Qt 5.8:  Chromium 53
             53.0.2785.148 (2016-08-31)
             5.8.0: Security fixes up to 55.0.2883.75 (2016-12-01)
    Qt 5.9:  Chromium 56
    (LTS)    56.0.2924.122 (2017-01-25)
             5.9.6: Security fixes up to 66.0.3359.170 (2018-05-10)
    Qt 5.10: Chromium 61
             61.0.3163.140 (2017-09-05)
             5.10.1: Security fixes up to 64.0.3282.140 (2018-02-01)
    Qt 5.11: Chromium 65
             65.0.3325.151 (.1: .230) (2018-03-06)
             5.11.2: Security fixes up to 68.0.3440.75 (2018-07-24)
    Qt 5.12: Chromium 69
             69.0.3497.128 (~2018-09-17)
             5.12.0: Security fixes up to 70.0.3538.67 (2018-10-16)
    Also see https://www.chromium.org/developers/calendar
    and https://chromereleases.googleblog.com/
    """
    profile = QWebEngineProfile()
    ua = profile.httpUserAgent()
    match = re.search(r' Chrome/([^ ]*) ', ua)
    if not match:
        return 'unknown'
    return match.group(1)
Esempio n. 11
0
 def __init__(self, parent, url=""):
     QWebEngineView.__init__(self, parent)
     self.navigator = parent
     self.webProfile = QWebEngineProfile(self)
     self.origineUrl = url
     self.currentUrl = url
     self.load(url)
     self.urlChanged.connect(self.on_urlChanged)
Esempio n. 12
0
 def __init__(self):
     super().__init__()
     self.appName = "Voce Browser"
     self.search_engine = "https://duckduckgo.com/"
     self.profile = QWebEngineProfile()
     self.assistant = VoceAssistant()
     self.windows = 0
     self.downloadManager = None
Esempio n. 13
0
 def __init__(self):
     super(BrowserTab, self).__init__()
     self.profile = QWebEngineProfile("storage", self)
     self.webpage = QWebEnginePage(self.profile, self)
     self.webpage.javaScriptConsoleMessage = lambda level, msg, line, sourceID: None
     self.setPage(self.webpage)
     self.load(QUrl("https://www.epicgames.com/store/"))
     self.show()
Esempio n. 14
0
 def __init__(self, parent=None):
     super(TeamtoolBrowser, self).__init__(parent)
     self.setupUi(self)
     self.browser = QWebEngineView()
     self.profile = QWebEngineProfile("somestorage", self.browser)
     self.webpage = QWebEnginePage(self.profile, self.browser)
     self.browser.setPage(self.webpage)
     self.initUI()
     self.eventUI()
Esempio n. 15
0
    def __init__(self,
                 base_url=None,
                 private=True,
                 profile_name=None,
                 gui=False):
        super().__init__()
        self.base_url = QUrl(base_url)
        self.__interceptor = Interceptor(self)
        if private:
            self.__profile = QWebEngineProfile()
        elif profile_name:
            self.__profile = QWebEngineProfile(profile_name)
        else:
            raise Exception(
                'please pass `profile_name` in case of `private` flag set to False'
            )
        self.__profile.setRequestInterceptor(self.__interceptor)
        self.__page = Page(self.__profile, None)
        self.__cookie_store = self.__profile.cookieStore()
        self.__cookie_store.cookieAdded.connect(self.__on_cookie_added)
        self.__cookies = []
        self.__async_result = None
        self.__loading = False

        self.__view = QWebEngineView()

        self.__page.setView(self.__view)
        self._qt_invocation = QtInvocation(self.__page)
        self.__channel = QWebChannel(self)
        self.__channel.registerObject("QtInvocation", self._qt_invocation)
        self.__page.setWebChannel(self.__channel)

        self.__page.loadStarted.connect(self.__load_started)
        self.__page.loadFinished.connect(self.__load_finished)
        self.__view.loadProgress.connect(self.__prg)
        self.__page.navigationRequested.connect(self.__navigation_requested)
        # self._qt_invocation.js_navigation_requested.connect(self.__page._js_gap_eventloop)
        self.__page.settings().setAttribute(
            self.__page.settings().LocalContentCanAccessRemoteUrls, True)
        self.__page.setUrl(QUrl('about:blank'))

        self.__view.setWindowState(Qt.WindowMaximized)
        if gui:
            self.__view.show()
def init_private_profile():
    """Init the private QWebEngineProfile."""
    global private_profile

    if qtutils.is_single_process():
        return

    private_profile = QWebEngineProfile()
    assert private_profile.isOffTheRecord()
    _init_profile(private_profile)
Esempio n. 17
0
def init_private_profile():
    """Init the private QWebEngineProfile."""
    global private_profile

    if not qtutils.is_single_process():
        private_profile = QWebEngineProfile()
        private_profile.setter = ProfileSetter(  # type: ignore[attr-defined]
            private_profile)
        assert private_profile.isOffTheRecord()
        private_profile.setter.init_profile()
Esempio n. 18
0
def create_profile():
    ans = getattr(create_profile, 'ans', None)
    if ans is None:
        ans = create_profile.ans = QWebEngineProfile(QApplication.instance())
        s = QWebEngineScript()
        s.setName('csslint.js')
        s.setSourceCode(csslint_js())
        s.setWorldId(QWebEngineScript.ApplicationWorld)
        ans.scripts().insert(s)
    return ans
Esempio n. 19
0
def _chromium_version():
    """Get the Chromium version for QtWebEngine."""
    if QWebEngineProfile is None:
        # This should never happen
        return 'unavailable'
    profile = QWebEngineProfile()
    ua = profile.httpUserAgent()
    match = re.search(r' Chrome/([^ ]*) ', ua)
    if not match:
        log.misc.error("Could not get Chromium version from: {}".format(ua))
        return 'unknown'
    return match.group(1)
Esempio n. 20
0
File: njaxt.py Progetto: oktak/njaXt
    def init_webview(self):
        self.webProfile = QWebEngineProfile(self.webView)
        self.webProfile.setHttpUserAgent(
            "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/59.0.3071.115 Safari/537.36")
        self.webProfile.setHttpAcceptLanguage("en-US,en;q=0.8")
        self.webProfile.settings().setAttribute(QWebEngineSettings.LocalStorageEnabled, True)
        self.set_scripts()
        self.webPage = QWebEnginePage(self.webProfile, self)

        self.webView.setPage(self.webPage)
        self.webView.loadProgress.connect(self.set_progress)
        self.webView.loadFinished.connect(lambda: self.lineEdit.setText(self.webView.url().toString()))
Esempio n. 21
0
 def create_webprofile(self):
     """Create a webengineprofile to use in all views."""
     if self.config.get("privacy_mode"):
         webprofile = QWebEngineProfile()
     else:
         webprofile = QWebEngineProfile.defaultProfile()
     debug("Browser session is private: {}".format(
         webprofile.isOffTheRecord()))
     if self.config.get("user_agent"):
         webprofile.setHttpUserAgent(self.config["user_agent"])
         debug('Set user agent to "{}"'.format(webprofile.httpUserAgent()))
     self.webprofile = webprofile
Esempio n. 22
0
        def __init__(self, parent=None):
            super().__init__(parent=parent)

            # Configure the intercepter for adding headers
            interceptor = TyphosWebRequestInterceptor(self)
            profile = QWebEngineProfile(self)
            profile.setRequestInterceptor(interceptor)

            # Use our custom page that will allow us to filter out javascript
            # log messages
            page = TyphosWebEnginePage(profile, self)
            self.setPage(page)
Esempio n. 23
0
def create_profile():
    ans = getattr(create_profile, 'ans', None)
    if ans is None:
        ans = QWebEngineProfile('viewer-lookup', QApplication.instance())
        ans.setHttpUserAgent(random_user_agent(allow_ie=False))
        ans.setCachePath(os.path.join(cache_dir(), 'ev2vl'))
        js = P('lookup.js', data=True, allow_user_override=False)
        insert_scripts(ans, create_script('lookup.js', js))
        s = ans.settings()
        s.setDefaultTextEncoding('utf-8')
        create_profile.ans = ans
    return ans
Esempio n. 24
0
 def getProfile(self):
     profile = QWebEngineProfile("myProfile")
     profile.cachePath = "/home/yyk/Desktop/cache"
     jsFile = constants.QTWEBCHANNELJS_FILE
     with open(jsFile, encoding="UTF-8") as file:
         js = file.read()
     script = QWebEngineScript()
     script.setSourceCode(js)
     script.setName('qwebchannel.js')
     script.setInjectionPoint(QWebEngineScript.DocumentCreation)
     script.setWorldId(QWebEngineScript.MainWorld)
     script.setRunsOnSubFrames(False)
     profile.scripts().insert(script)
     return profile
Esempio n. 25
0
    def __init__(self, direcciones):
        self.browser = QWebEngineView()
        self.browser.resize(500,500)
        self.profile = QWebEngineProfile('storage', self.browser)
        self.webpage = QWebEnginePage(self.profile, self.browser)
        self.browser.setPage(self.webpage)
        m = MapaUrl()
        m.tipomapa(0)
        m.set_marcadores(direcciones)
        #url = m.get_url()
        url = m.mapa_dinamico()
        print(url)

        self.browser.load(QUrl(url))
        self.browser.show()
Esempio n. 26
0
def _init_profiles():
    """Init the two used QWebEngineProfiles."""
    global default_profile, private_profile
    default_profile = QWebEngineProfile.defaultProfile()
    default_profile.setCachePath(os.path.join(standarddir.cache(),
                                              'webengine'))
    default_profile.setPersistentStoragePath(
        os.path.join(standarddir.data(), 'webengine'))
    _init_stylesheet(default_profile)
    _set_user_agent(default_profile)

    private_profile = QWebEngineProfile()
    assert private_profile.isOffTheRecord()
    _init_stylesheet(private_profile)
    _set_user_agent(private_profile)
Esempio n. 27
0
    def _provider_browser(self, window):
        from PyQt5.QtWebEngineWidgets import QWebEngineProfile

        from .gui.browser.webview import WebEngineUrlRequestInterceptor
        from .gui.browser.webview import MyWebEnginePage
        from .gui.browser.webview import MyWebEngineView

        browser = MyWebEngineView()
        profile = QWebEngineProfile(window)
        interceptor = WebEngineUrlRequestInterceptor(window)
        profile.setRequestInterceptor(interceptor)
        page = MyWebEnginePage(profile, window)
        browser.setPage(page)

        return browser
Esempio n. 28
0
def _chromium_version():
    """Get the Chromium version for QtWebEngine.

    This can also be checked by looking at this file with the right Qt tag:
    http://code.qt.io/cgit/qt/qtwebengine.git/tree/tools/scripts/version_resolver.py#n41

    Quick reference:

    Qt 5.7:  Chromium 49
             49.0.2623.111 (2016-03-31)
             5.7.1: Security fixes up to 54.0.2840.87 (2016-11-01)

    Qt 5.8:  Chromium 53
             53.0.2785.148 (2016-08-31)
             5.8.0: Security fixes up to 55.0.2883.75 (2016-12-01)

    Qt 5.9:  Chromium 56
    (LTS)    56.0.2924.122 (2017-01-25)
             5.9.8: Security fixes up to 72.0.3626.121 (2019-03-01)

    Qt 5.10: Chromium 61
             61.0.3163.140 (2017-09-05)
             5.10.1: Security fixes up to 64.0.3282.140 (2018-02-01)

    Qt 5.11: Chromium 65
             65.0.3325.151 (.1: .230) (2018-03-06)
             5.11.3: Security fixes up to 70.0.3538.102 (2018-11-09)

    Qt 5.12: Chromium 69
    (LTS)    69.0.3497.113 (2018-09-27)
             5.12.3: Security fixes up to 73.0.3683.75 (2019-03-12)

    Qt 5.13: (in development) Chromium 73
             73.0.3683.105 (~2019-02-28)

    Also see https://www.chromium.org/developers/calendar
    and https://chromereleases.googleblog.com/
    """
    if QWebEngineProfile is None:
        # This should never happen
        return 'unavailable'
    profile = QWebEngineProfile()
    ua = profile.httpUserAgent()
    match = re.search(r' Chrome/([^ ]*) ', ua)
    if not match:
        log.misc.error("Could not get Chromium version from: {}".format(ua))
        return 'unknown'
    return match.group(1)
Esempio n. 29
0
    def __init__(self, *args, **kwargs):
        # Strip out arguments we handle that are different from QMainWindow:
        if 'width' in kwargs:
            self.width = kwargs['width']
            del kwargs['width']
        else:
            self.width = 1024
        if 'height' in kwargs:
            self.height = kwargs['height']
            del kwargs['height']
        else:
            # Short enough to fit in XGA, 768 height:
            self.height = 735

        # Then run the default constructor.
        super().__init__(*args, **kwargs)

        self.browserviews = []

        self.profile = QWebEngineProfile()
        # print("Profile initially off the record?",
        #       self.profile.isOffTheRecord())

        # "Off the record" doesn't mean much: QtWebEngine still
        # stores cache and maybe persistent cookies.
        # Here are some other attempts at privacy that might help a little:
        # self.cachedir = tempfile.mkdtemp()
        # self.profile.setCachePath(self.cachedir)
        # self.profile.setPersistentStoragePath(self.cachedir)
        # self.profile.setPersistentCookiesPolicy(self.profile.NoPersistentCookies);
        # but even with all those, QtWebEngine still stores a bunch of crap in
        # .local/share/quickbrowse/QtWebEngine/Default/
        # But we can prevent that by lying about $HOME:
        os.environ["HOME"] = tempfile.mkdtemp()

        self.init_tab_name_len = 40

        self.init_chrome()

        # Resize to fit on an XGA screen, allowing for window chrome.
        # XXX Should check the screen size and see if it can be bigger.
        self.resize(self.width, self.height)

        # Set up the listener for remote commands, the filename
        # and the buffer where we'll store those commands:
        self.cmdsockname = None
        self.cmdread = b''
        self.set_up_listener()
Esempio n. 30
0
def chromium_version():
    """
    Get the Chromium version for QtWebEngine.

    This can also be checked by looking at this file with the right Qt tag:
    https://github.com/qt/qtwebengine/blob/dev/tools/scripts/version_resolver.py#L41
    """
    if QWebEngineProfile is None:
        # This should never happen
        return 'unavailable'
    profile = QWebEngineProfile()
    ua = profile.httpUserAgent()
    match = re.search(r' Chrome/([^ ]*) ', ua)
    if not match:
        logging.error("Could not get Chromium version from: {}".format(ua))
        return 'unknown'
    return match.group(1)