def init(args, crash_handler): """Initialize everything. Args: args: The argparse namespace. crash_handler: The CrashHandler instance. """ log.init.debug("Starting init...") qApp.setQuitOnLastWindowClosed(False) _init_icon() try: _init_modules(args, crash_handler) except (OSError, UnicodeDecodeError, browsertab.WebTabError) as e: error.handle_fatal_exc(e, args, "Error while initializing!", pre_text="Error while initializing") sys.exit(usertypes.Exit.err_init) log.init.debug("Initializing eventfilter...") event_filter = EventFilter(qApp) qApp.installEventFilter(event_filter) objreg.register('event-filter', event_filter) log.init.debug("Connecting signals...") qApp.focusChanged.connect(on_focus_changed) _process_args(args) QDesktopServices.setUrlHandler('http', open_desktopservices_url) QDesktopServices.setUrlHandler('https', open_desktopservices_url) QDesktopServices.setUrlHandler('qute', open_desktopservices_url) log.init.debug("Init done!") crash_handler.raise_crashdlg()
def _init_key_config(parent): """Initialize the key config. Args: parent: The parent to use for the KeyConfigParser. """ args = objreg.get('args') try: key_config = keyconf.KeyConfigParser(standarddir.config(), 'keys.conf', args.relaxed_config, parent=parent) except (keyconf.KeyConfigError, UnicodeDecodeError) as e: log.init.exception(e) errstr = "Error while reading key config:\n" if e.lineno is not None: errstr += "In line {}: ".format(e.lineno) error.handle_fatal_exc(e, args, "Error while reading key config!", pre_text=errstr) # We didn't really initialize much so far, so we just quit hard. sys.exit(usertypes.Exit.err_key_config) else: objreg.register('key-config', key_config) if standarddir.config() is not None: save_manager = objreg.get('save-manager') filename = os.path.join(standarddir.config(), 'keys.conf') save_manager.add_saveable( 'key-config', key_config.save, key_config.config_dirty, config_opt=('general', 'auto-save-config'), filename=filename, dirty=key_config.is_dirty)
def _shutdown(self, status, restart): # noqa """Second stage of shutdown.""" log.destroy.debug("Stage 2 of shutting down...") if qApp is None: # No QApplication exists yet, so quit hard. sys.exit(status) # Remove eventfilter try: log.destroy.debug("Removing eventfilter...") event_filter = objreg.get('event-filter', None) if event_filter is not None: qApp.removeEventFilter(event_filter) except AttributeError: pass # Close all windows QApplication.closeAllWindows() # Shut down IPC try: objreg.get('ipc-server').shutdown() except KeyError: pass # Save everything try: save_manager = objreg.get('save-manager') except KeyError: log.destroy.debug("Save manager not initialized yet, so not " "saving anything.") else: for key in save_manager.saveables: try: save_manager.save(key, is_exit=True) except OSError as e: error.handle_fatal_exc( e, self._args, "Error while saving!", pre_text="Error while saving {}".format(key)) # Disable storage so removing tempdir will work websettings.shutdown() # Re-enable faulthandler to stdout, then remove crash log log.destroy.debug("Deactivating crash log...") objreg.get('crash-handler').destroy_crashlogfile() # Delete temp basedir if ((self._args.temp_basedir or self._args.temp_basedir_restarted) and not restart): atexit.register(shutil.rmtree, self._args.basedir, ignore_errors=True) # Delete temp download dir downloads.temp_download_manager.cleanup() # If we don't kill our custom handler here we might get segfaults log.destroy.debug("Deactivating message handler...") qInstallMessageHandler(None) # Now we can hopefully quit without segfaults log.destroy.debug("Deferring QApplication::exit...") objreg.get('signal-handler').deactivate() session_manager = objreg.get('session-manager', None) if session_manager is not None: session_manager.delete_autosave() # We use a singleshot timer to exit here to minimize the likelihood of # segfaults. QTimer.singleShot(0, functools.partial(qApp.exit, status))
def display_error(exc, args): """Display a message box with an IPC error.""" error.handle_fatal_exc( exc, args, "Error while connecting to running instance!", post_text="Maybe another instance is running but frozen?", )
def _shutdown(self, status, restart): """Second stage of shutdown.""" log.destroy.debug("Stage 2 of shutting down...") if qApp is None: # No QApplication exists yet, so quit hard. sys.exit(status) # Remove eventfilter try: log.destroy.debug("Removing eventfilter...") qApp.removeEventFilter(objreg.get('event-filter')) except AttributeError: pass # Close all windows QApplication.closeAllWindows() # Shut down IPC try: objreg.get('ipc-server').shutdown() except KeyError: pass # Save everything try: save_manager = objreg.get('save-manager') except KeyError: log.destroy.debug("Save manager not initialized yet, so not " "saving anything.") else: for key in save_manager.saveables: try: save_manager.save(key, is_exit=True) except OSError as e: error.handle_fatal_exc( e, self._args, "Error while saving!", pre_text="Error while saving {}".format(key)) # Disable storage so removing tempdir will work QWebSettings.setIconDatabasePath('') QWebSettings.setOfflineWebApplicationCachePath('') QWebSettings.globalSettings().setLocalStoragePath('') # Re-enable faulthandler to stdout, then remove crash log log.destroy.debug("Deactivating crash log...") objreg.get('crash-handler').destroy_crashlogfile() # Delete temp basedir if ((self._args.temp_basedir or self._args.temp_basedir_restarted) and not restart): atexit.register(shutil.rmtree, self._args.basedir, ignore_errors=True) # If we don't kill our custom handler here we might get segfaults log.destroy.debug("Deactivating message handler...") qInstallMessageHandler(None) # Now we can hopefully quit without segfaults log.destroy.debug("Deferring QApplication::exit...") objreg.get('signal-handler').deactivate() # We use a singleshot timer to exit here to minimize the likelihood of # segfaults. QTimer.singleShot(0, functools.partial(qApp.exit, status))
def shutdown(self): """Save all saveables when shutting down.""" for key in self.saveables: try: self.save(key, is_exit=True) except OSError as e: error.handle_fatal_exc( e, self._args, "Error while saving!", pre_text="Error while saving {}".format(key))
def test_no_err_windows(caplog): """Test handle_fatal_exc uwith no_err_windows = True.""" try: raise ValueError("exception") except ValueError as e: with caplog.atLevel(logging.ERROR): error.handle_fatal_exc(e, Args(no_err_windows=True), 'title', pre_text='pre', post_text='post') msgs = [rec.message for rec in caplog.records()] assert msgs[0] == 'Handling fatal ValueError with --no-err-windows!' assert msgs[1] == 'title: title' assert msgs[2] == 'pre_text: pre' assert msgs[3] == 'post_text: post'
def _shutdown(self, status): """Second stage of shutdown.""" log.destroy.debug("Stage 2 of shutting down...") if qApp is None: # No QApplication exists yet, so quit hard. sys.exit(status) # Remove eventfilter try: log.destroy.debug("Removing eventfilter...") qApp.removeEventFilter(objreg.get("event-filter")) except AttributeError: pass # Close all windows QApplication.closeAllWindows() # Shut down IPC try: objreg.get("ipc-server").shutdown() except KeyError: pass # Save everything try: save_manager = objreg.get("save-manager") except KeyError: log.destroy.debug("Save manager not initialized yet, so not " "saving anything.") else: for key in save_manager.saveables: try: save_manager.save(key, is_exit=True) except OSError as e: error.handle_fatal_exc( e, self._args, "Error while saving!", pre_text="Error while saving {}".format(key) ) # Disable storage so removing tempdir will work QWebSettings.setIconDatabasePath("") QWebSettings.setOfflineWebApplicationCachePath("") QWebSettings.globalSettings().setLocalStoragePath("") # Re-enable faulthandler to stdout, then remove crash log log.destroy.debug("Deactivating crash log...") objreg.get("crash-handler").destroy_crashlogfile() # Delete temp basedir if self._args.temp_basedir: atexit.register(shutil.rmtree, self._args.basedir, ignore_errors=True) # If we don't kill our custom handler here we might get segfaults log.destroy.debug("Deactivating message handler...") qInstallMessageHandler(None) # Now we can hopefully quit without segfaults log.destroy.debug("Deferring QApplication::exit...") objreg.get("signal-handler").deactivate() # We use a singleshot timer to exit here to minimize the likelihood of # segfaults. QTimer.singleShot(0, functools.partial(qApp.exit, status))
def _init_late_modules(args): """Initialize modules which can be inited after the window is shown.""" log.init.debug("Reading web history...") reader = objreg.get("web-history").async_read() with debug.log_time(log.init, "Reading history"): while True: QApplication.processEvents() try: next(reader) except StopIteration: break except (OSError, UnicodeDecodeError) as e: error.handle_fatal_exc(e, args, "Error while initializing!", pre_text="Error while initializing") sys.exit(usertypes.Exit.err_init)
def _init_late_modules(args): """Initialize modules which can be inited after the window is shown.""" log.init.debug("Reading web history...") reader = objreg.get('web-history').async_read() with debug.log_time(log.init, 'Reading history'): while True: QApplication.processEvents() try: next(reader) except StopIteration: break except (OSError, UnicodeDecodeError) as e: error.handle_fatal_exc(e, args, "Error while initializing!", pre_text="Error while initializing") sys.exit(usertypes.Exit.err_init)
def test_no_err_windows(caplog, exc, name, exc_text): """Test handle_fatal_exc with no_err_windows = True.""" try: raise exc except Exception as e: with caplog.atLevel(logging.ERROR): error.handle_fatal_exc(e, Args(no_err_windows=True), 'title', pre_text='pre', post_text='post') msgs = [rec.message for rec in caplog.records()] expected = [ 'Handling fatal {} with --no-err-windows!'.format(name), 'title: title', 'pre_text: pre', 'post_text: post', 'exception text: {}'.format(exc_text), ] assert msgs[-5:] == expected
def test_err_windows(qtbot, qapp, fake_args, pre_text, post_text, expected): def err_window_check(): w = qapp.activeModalWidget() try: qtbot.add_widget(w) if not utils.is_mac: assert w.windowTitle() == 'title' assert w.icon() == QMessageBox.Critical assert w.standardButtons() == QMessageBox.Ok assert w.text() == expected finally: w.close() fake_args.no_err_windows = False QTimer.singleShot(0, err_window_check) error.handle_fatal_exc(ValueError("exception"), fake_args, 'title', pre_text=pre_text, post_text=post_text)
def test_err_windows(qtbot, qapp, pre_text, post_text, expected): @pyqtSlot() def err_window_check(): w = qapp.activeModalWidget() try: qtbot.add_widget(w) if sys.platform != 'darwin': assert w.windowTitle() == 'title' assert w.icon() == QMessageBox.Critical assert w.standardButtons() == QMessageBox.Ok assert w.text() == expected finally: w.close() QTimer.singleShot(0, err_window_check) error.handle_fatal_exc(ValueError("exception"), Args(no_err_windows=False), 'title', pre_text=pre_text, post_text=post_text)
def _init_main_config(parent=None): """Initialize the main config. Args: parent: The parent to pass to ConfigManager. """ args = objreg.get('args') config_obj = ConfigManager(parent=parent) try: config_obj.read(standarddir.config(), 'qutebrowser.conf', relaxed=args.relaxed_config) except (configexc.Error, configparser.Error, UnicodeDecodeError) as e: log.init.exception(e) errstr = "Error while reading config:" try: errstr += "\n\n{} -> {}:".format(e.section, e.option) except AttributeError: pass errstr += "\n" error.handle_fatal_exc(e, args, "Error while reading config!", pre_text=errstr) # We didn't really initialize much so far, so we just quit hard. sys.exit(usertypes.Exit.err_config) else: objreg.register('config', config_obj) if standarddir.config() is not None: filename = os.path.join(standarddir.config(), 'qutebrowser.conf') save_manager = objreg.get('save-manager') save_manager.add_saveable('config', config_obj.save, config_obj.changed, config_opt=('general', 'auto-save-config'), filename=filename) for sect in config_obj.sections.values(): for opt in sect.values.values(): if opt.values['conf'] is None: # Option added to built-in defaults but not in user's # config yet save_manager.save('config', explicit=True, force=True) return
def init(args, crash_handler): """Initialize everything. Args: args: The argparse namespace. crash_handler: The CrashHandler instance. """ log.init.debug("Starting init...") qApp.setQuitOnLastWindowClosed(False) qApp.setOrganizationName("qutebrowser") qApp.setApplicationName("qutebrowser") qApp.setApplicationVersion(qutebrowser.__version__) _init_icon() utils.actute_warning() try: _init_modules(args, crash_handler) except (OSError, UnicodeDecodeError) as e: error.handle_fatal_exc(e, args, "Error while initializing!", pre_text="Error while initializing") sys.exit(usertypes.Exit.err_init) QTimer.singleShot(0, functools.partial(_process_args, args)) QTimer.singleShot(10, functools.partial(_init_late_modules, args)) log.init.debug("Initializing eventfilter...") event_filter = EventFilter(qApp) qApp.installEventFilter(event_filter) objreg.register('event-filter', event_filter) log.init.debug("Connecting signals...") config_obj = objreg.get('config') config_obj.style_changed.connect(style.get_stylesheet.cache_clear) qApp.focusChanged.connect(on_focus_changed) qApp.focusChanged.connect(message.on_focus_changed) QDesktopServices.setUrlHandler('http', open_desktopservices_url) QDesktopServices.setUrlHandler('https', open_desktopservices_url) QDesktopServices.setUrlHandler('qute', open_desktopservices_url) log.init.debug("Init done!") crash_handler.raise_crashdlg()
def test_no_err_windows(caplog, exc, name, exc_text, fake_args): """Test handle_fatal_exc with no_err_windows = True.""" fake_args.no_err_windows = True try: raise exc except Exception as e: with caplog.at_level(logging.ERROR): error.handle_fatal_exc(e, fake_args, 'title', pre_text='pre', post_text='post') expected = [ 'Handling fatal {} with --no-err-windows!'.format(name), '', 'title: title', 'pre_text: pre', 'post_text: post', 'exception text: {}'.format(exc_text), ] assert caplog.messages == ['\n'.join(expected)]
def test_no_err_windows(caplog, exc, name, exc_text): """Test handle_fatal_exc with no_err_windows = True.""" try: raise exc except Exception as e: with caplog.at_level(logging.ERROR): error.handle_fatal_exc(e, Args(no_err_windows=True), 'title', pre_text='pre', post_text='post') assert len(caplog.records) == 1 expected = [ 'Handling fatal {} with --no-err-windows!'.format(name), '', 'title: title', 'pre_text: pre', 'post_text: post', 'exception text: {}'.format(exc_text), ] assert caplog.records[0].msg == '\n'.join(expected)
def init(args, crash_handler): """Initialize everything. Args: args: The argparse namespace. crash_handler: The CrashHandler instance. """ log.init.debug("Starting init...") crash_handler.init_faulthandler() q_app.setQuitOnLastWindowClosed(False) _init_icon() loader.init() loader.load_components() try: _init_modules(args, crash_handler) except (OSError, UnicodeDecodeError, browsertab.WebTabError) as e: error.handle_fatal_exc(e, args, "Error while initializing!", pre_text="Error while initializing") sys.exit(usertypes.Exit.err_init) log.init.debug("Initializing eventfilter...") event_filter = EventFilter(q_app) q_app.installEventFilter(event_filter) objreg.register('event-filter', event_filter) log.init.debug("Connecting signals...") q_app.focusChanged.connect(on_focus_changed) _process_args(args) QDesktopServices.setUrlHandler('http', open_desktopservices_url) QDesktopServices.setUrlHandler('https', open_desktopservices_url) QDesktopServices.setUrlHandler('qute', open_desktopservices_url) log.init.debug("Init done!") crash_handler.raise_crashdlg()
def test_err_windows(qtbot, qapp, pre_text, post_text, expected, caplog): def err_window_check(): w = qapp.activeModalWidget() assert w is not None try: qtbot.add_widget(w) if not utils.is_mac: assert w.windowTitle() == 'title' assert w.icon() == QMessageBox.Critical assert w.standardButtons() == QMessageBox.Ok assert w.text() == expected finally: w.close() QTimer.singleShot(10, err_window_check) with caplog.at_level(logging.ERROR): error.handle_fatal_exc(ValueError("exception"), 'title', pre_text=pre_text, post_text=post_text, no_err_windows=False)
def init(*, args: argparse.Namespace, crash_handler: crashsignal.CrashHandler, quitter: 'Quitter'): """Initialize everything.""" log.init.debug("Starting init...") crash_handler.init_faulthandler() q_app.setQuitOnLastWindowClosed(False) quitter.shutting_down.connect(QApplication.closeAllWindows) _init_icon() loader.init() loader.load_components() try: _init_modules(args=args, crash_handler=crash_handler, quitter=quitter) except (OSError, UnicodeDecodeError, browsertab.WebTabError) as e: error.handle_fatal_exc(e, args, "Error while initializing!", pre_text="Error while initializing") sys.exit(usertypes.Exit.err_init) log.init.debug("Initializing eventfilter...") event_filter = EventFilter(q_app) event_filter.install() quitter.shutting_down.connect(event_filter.shutdown) log.init.debug("Connecting signals...") q_app.focusChanged.connect(on_focus_changed) # type: ignore _process_args(args) for scheme in ['http', 'https', 'qute']: QDesktopServices.setUrlHandler( scheme, open_desktopservices_url) # type: ignore log.init.debug("Init done!") crash_handler.raise_crashdlg()
def _init_main_config(parent=None): """Initialize the main config. Args: parent: The parent to pass to ConfigManager. """ args = objreg.get('args') config_obj = ConfigManager(parent=parent) try: config_obj.read(standarddir.config(), 'qutebrowser.conf', relaxed=args.relaxed_config) except (configexc.Error, configparser.Error, UnicodeDecodeError) as e: log.init.exception(e) errstr = "Error while reading config:" try: errstr += "\n\n{} -> {}:".format( e.section, e.option) except AttributeError: pass errstr += "\n" error.handle_fatal_exc(e, args, "Error while reading config!", pre_text=errstr) # We didn't really initialize much so far, so we just quit hard. sys.exit(usertypes.Exit.err_config) else: objreg.register('config', config_obj) if standarddir.config() is not None: filename = os.path.join(standarddir.config(), 'qutebrowser.conf') save_manager = objreg.get('save-manager') save_manager.add_saveable( 'config', config_obj.save, config_obj.changed, config_opt=('general', 'auto-save-config'), filename=filename) for sect in config_obj.sections.values(): for opt in sect.values.values(): if opt.values['conf'] is None: # Option added to built-in defaults but not in user's # config yet save_manager.save('config', explicit=True, force=True) return
def _process_args(args): """Open startpage etc. and process commandline args.""" if not args.override_restore: _load_session(args.session) session_manager = objreg.get('session-manager') if not session_manager.did_load: log.init.debug("Initializing main window...") if config.val.content.private_browsing and qtutils.is_single_process(): err = Exception("Private windows are unavailable with " "the single-process process model.") error.handle_fatal_exc(err, args, 'Cannot start in private mode') sys.exit(usertypes.Exit.err_init) window = mainwindow.MainWindow(private=None) if not args.nowindow: window.show() q_app.setActiveWindow(window) process_pos_args(args.command) _open_startpage() _open_special_pages(args) delta = datetime.datetime.now() - earlyinit.START_TIME log.init.debug("Init finished after {}s".format(delta.total_seconds()))
def _process_args(args): """Open startpage etc. and process commandline args.""" if not args.override_restore: _load_session(args.session) if not sessions.session_manager.did_load: log.init.debug("Initializing main window...") if config.val.content.private_browsing and qtutils.is_single_process(): err = Exception("Private windows are unavailable with " "the single-process process model.") error.handle_fatal_exc(err, args, 'Cannot start in private mode') sys.exit(usertypes.Exit.err_init) window = mainwindow.MainWindow(private=None) if not args.nowindow: window.show() q_app.setActiveWindow(window) process_pos_args(args.command) _open_startpage() _open_special_pages(args) delta = datetime.datetime.now() - earlyinit.START_TIME log.init.debug("Init finished after {}s".format(delta.total_seconds()))
def init(*, args: argparse.Namespace) -> None: """Initialize everything.""" log.init.debug("Starting init...") crashsignal.crash_handler.init_faulthandler() objects.qapp.setQuitOnLastWindowClosed(False) quitter.instance.shutting_down.connect(QApplication.closeAllWindows) _init_icon() _init_pulseaudio() loader.init() loader.load_components() try: _init_modules(args=args) except (OSError, UnicodeDecodeError, browsertab.WebTabError) as e: error.handle_fatal_exc(e, "Error while initializing!", no_err_windows=args.no_err_windows, pre_text="Error while initializing") sys.exit(usertypes.Exit.err_init) log.init.debug("Initializing eventfilter...") eventfilter.init() log.init.debug("Connecting signals...") objects.qapp.focusChanged.connect(on_focus_changed) _process_args(args) for scheme in ['http', 'https', 'qute']: QDesktopServices.setUrlHandler( scheme, open_desktopservices_url) log.init.debug("Init done!") crashsignal.crash_handler.raise_crashdlg()
def _init_modules(args, crash_handler): """Initialize all 'modules' which need to be initialized. Args: args: The argparse namespace. crash_handler: The CrashHandler instance. """ # pylint: disable=too-many-statements log.init.debug("Initializing prompts...") prompt.init() log.init.debug("Initializing save manager...") save_manager = savemanager.SaveManager(qApp) objreg.register('save-manager', save_manager) config.late_init(save_manager) log.init.debug("Initializing network...") networkmanager.init() log.init.debug("Initializing proxy...") proxy.init() log.init.debug("Initializing readline-bridge...") readline_bridge = readline.ReadlineBridge() objreg.register('readline-bridge', readline_bridge) log.init.debug("Initializing sql...") try: sql.init(os.path.join(standarddir.data(), 'history.sqlite')) except sql.SqlException as e: error.handle_fatal_exc(e, args, 'Error initializing SQL', pre_text='Error initializing SQL') sys.exit(usertypes.Exit.err_init) log.init.debug("Initializing command history...") cmdhistory.init() log.init.debug("Initializing web history...") history.init(qApp) log.init.debug("Initializing crashlog...") if not args.no_err_windows: crash_handler.handle_segfault() log.init.debug("Initializing sessions...") sessions.init(qApp) log.init.debug("Initializing websettings...") websettings.init(args) log.init.debug("Initializing adblock...") host_blocker = adblock.HostBlocker() host_blocker.read_hosts() objreg.register('host-blocker', host_blocker) log.init.debug("Initializing quickmarks...") quickmark_manager = urlmarks.QuickmarkManager(qApp) objreg.register('quickmark-manager', quickmark_manager) log.init.debug("Initializing bookmarks...") bookmark_manager = urlmarks.BookmarkManager(qApp) objreg.register('bookmark-manager', bookmark_manager) log.init.debug("Initializing cookies...") cookie_jar = cookies.CookieJar(qApp) ram_cookie_jar = cookies.RAMCookieJar(qApp) objreg.register('cookie-jar', cookie_jar) objreg.register('ram-cookie-jar', ram_cookie_jar) log.init.debug("Initializing cache...") diskcache = cache.DiskCache(standarddir.cache(), parent=qApp) objreg.register('cache', diskcache) log.init.debug("Misc initialization...") if config.val.window.hide_wayland_decoration: os.environ['QT_WAYLAND_DISABLE_WINDOWDECORATION'] = '1' else: os.environ.pop('QT_WAYLAND_DISABLE_WINDOWDECORATION', None) macros.init() # Init backend-specific stuff browsertab.init()
def _init_modules(args, crash_handler): """Initialize all 'modules' which need to be initialized. Args: args: The argparse namespace. crash_handler: The CrashHandler instance. """ log.init.debug("Initializing save manager...") save_manager = savemanager.SaveManager(qApp) objreg.register('save-manager', save_manager) configinit.late_init(save_manager) log.init.debug("Checking backend requirements...") backendproblem.init() log.init.debug("Initializing prompts...") prompt.init() log.init.debug("Initializing network...") networkmanager.init() log.init.debug("Initializing proxy...") proxy.init() log.init.debug("Initializing readline-bridge...") readline_bridge = readline.ReadlineBridge() objreg.register('readline-bridge', readline_bridge) try: log.init.debug("Initializing sql...") sql.init(os.path.join(standarddir.data(), 'history.sqlite')) log.init.debug("Initializing web history...") history.init(qApp) except sql.SqlError as e: if e.environmental: error.handle_fatal_exc(e, args, 'Error initializing SQL', pre_text='Error initializing SQL') sys.exit(usertypes.Exit.err_init) else: raise log.init.debug("Initializing completion...") completiondelegate.init() log.init.debug("Initializing command history...") cmdhistory.init() log.init.debug("Initializing crashlog...") if not args.no_err_windows: crash_handler.handle_segfault() log.init.debug("Initializing sessions...") sessions.init(qApp) log.init.debug("Initializing websettings...") websettings.init(args) log.init.debug("Initializing adblock...") host_blocker = adblock.HostBlocker() host_blocker.read_hosts() objreg.register('host-blocker', host_blocker) log.init.debug("Initializing quickmarks...") quickmark_manager = urlmarks.QuickmarkManager(qApp) objreg.register('quickmark-manager', quickmark_manager) log.init.debug("Initializing bookmarks...") bookmark_manager = urlmarks.BookmarkManager(qApp) objreg.register('bookmark-manager', bookmark_manager) log.init.debug("Initializing cookies...") cookie_jar = cookies.CookieJar(qApp) ram_cookie_jar = cookies.RAMCookieJar(qApp) objreg.register('cookie-jar', cookie_jar) objreg.register('ram-cookie-jar', ram_cookie_jar) log.init.debug("Initializing cache...") diskcache = cache.DiskCache(standarddir.cache(), parent=qApp) objreg.register('cache', diskcache) log.init.debug("Initializing downloads...") download_manager = qtnetworkdownloads.DownloadManager(parent=qApp) objreg.register('qtnetwork-download-manager', download_manager) log.init.debug("Initializing Greasemonkey...") greasemonkey.init() log.init.debug("Misc initialization...") macros.init() # Init backend-specific stuff browsertab.init()
def display_error(exc, args): """Display a message box with an IPC error.""" error.handle_fatal_exc(exc, "Error while connecting to running instance!", no_err_windows=args.no_err_windows)
def display_error(exc, args): """Display a message box with an IPC error.""" error.handle_fatal_exc( exc, args, "Error while connecting to running instance!", post_text="Maybe another instance is running but frozen?")
def _init_modules(*, args): """Initialize all 'modules' which need to be initialized. Args: args: The argparse namespace. """ log.init.debug("Initializing save manager...") save_manager = savemanager.SaveManager(q_app) objreg.register('save-manager', save_manager) quitter.instance.shutting_down.connect(save_manager.shutdown) configinit.late_init(save_manager) log.init.debug("Checking backend requirements...") backendproblem.init(args=args, save_manager=save_manager) log.init.debug("Initializing prompts...") prompt.init() log.init.debug("Initializing network...") networkmanager.init() log.init.debug("Initializing proxy...") proxy.init() quitter.instance.shutting_down.connect(proxy.shutdown) log.init.debug("Initializing downloads...") downloads.init() quitter.instance.shutting_down.connect(downloads.shutdown) try: log.init.debug("Initializing SQL...") sql.init(os.path.join(standarddir.data(), 'history.sqlite')) log.init.debug("Initializing web history...") history.init(q_app) except sql.KnownError as e: error.handle_fatal_exc(e, 'Error initializing SQL', pre_text='Error initializing SQL', no_err_windows=args.no_err_windows) sys.exit(usertypes.Exit.err_init) log.init.debug("Initializing command history...") cmdhistory.init() log.init.debug("Initializing sessions...") sessions.init(q_app) quitter.instance.shutting_down.connect(sessions.shutdown) log.init.debug("Initializing websettings...") websettings.init(args) quitter.instance.shutting_down.connect(websettings.shutdown) if not args.no_err_windows: crashsignal.crash_handler.display_faulthandler() log.init.debug("Initializing quickmarks...") quickmark_manager = urlmarks.QuickmarkManager(q_app) objreg.register('quickmark-manager', quickmark_manager) log.init.debug("Initializing bookmarks...") bookmark_manager = urlmarks.BookmarkManager(q_app) objreg.register('bookmark-manager', bookmark_manager) log.init.debug("Initializing cookies...") cookies.init(q_app) log.init.debug("Initializing cache...") cache.init(q_app) log.init.debug("Initializing downloads...") download_manager = qtnetworkdownloads.DownloadManager(parent=q_app) objreg.register('qtnetwork-download-manager', download_manager) log.init.debug("Initializing Greasemonkey...") greasemonkey.init() log.init.debug("Misc initialization...") macros.init() # Init backend-specific stuff browsertab.init()
def _init_modules(args, crash_handler): """Initialize all 'modules' which need to be initialized. Args: args: The argparse namespace. crash_handler: The CrashHandler instance. """ # pylint: disable=too-many-statements log.init.debug("Initializing save manager...") save_manager = savemanager.SaveManager(qApp) objreg.register('save-manager', save_manager) configinit.late_init(save_manager) log.init.debug("Checking backend requirements...") backendproblem.init() log.init.debug("Initializing prompts...") prompt.init() log.init.debug("Initializing network...") networkmanager.init() log.init.debug("Initializing proxy...") proxy.init() log.init.debug("Initializing readline-bridge...") readline_bridge = readline.ReadlineBridge() objreg.register('readline-bridge', readline_bridge) log.init.debug("Initializing sql...") try: sql.init(os.path.join(standarddir.data(), 'history.sqlite')) except sql.SqlError as e: error.handle_fatal_exc(e, args, 'Error initializing SQL', pre_text='Error initializing SQL') sys.exit(usertypes.Exit.err_init) log.init.debug("Initializing completion...") completiondelegate.init() log.init.debug("Initializing command history...") cmdhistory.init() log.init.debug("Initializing web history...") history.init(qApp) log.init.debug("Initializing crashlog...") if not args.no_err_windows: crash_handler.handle_segfault() log.init.debug("Initializing sessions...") sessions.init(qApp) log.init.debug("Initializing websettings...") websettings.init(args) log.init.debug("Initializing adblock...") host_blocker = adblock.HostBlocker() host_blocker.read_hosts() objreg.register('host-blocker', host_blocker) log.init.debug("Initializing quickmarks...") quickmark_manager = urlmarks.QuickmarkManager(qApp) objreg.register('quickmark-manager', quickmark_manager) log.init.debug("Initializing bookmarks...") bookmark_manager = urlmarks.BookmarkManager(qApp) objreg.register('bookmark-manager', bookmark_manager) log.init.debug("Initializing cookies...") cookie_jar = cookies.CookieJar(qApp) ram_cookie_jar = cookies.RAMCookieJar(qApp) objreg.register('cookie-jar', cookie_jar) objreg.register('ram-cookie-jar', ram_cookie_jar) log.init.debug("Initializing cache...") diskcache = cache.DiskCache(standarddir.cache(), parent=qApp) objreg.register('cache', diskcache) log.init.debug("Misc initialization...") if config.val.window.hide_wayland_decoration: os.environ['QT_WAYLAND_DISABLE_WINDOWDECORATION'] = '1' else: os.environ.pop('QT_WAYLAND_DISABLE_WINDOWDECORATION', None) macros.init() # Init backend-specific stuff browsertab.init()
def _init_modules(args, crash_handler): """Initialize all 'modules' which need to be initialized. Args: args: The argparse namespace. crash_handler: The CrashHandler instance. """ log.init.debug("Initializing save manager...") save_manager = savemanager.SaveManager(q_app) objreg.register('save-manager', save_manager) configinit.late_init(save_manager) log.init.debug("Checking backend requirements...") backendproblem.init() log.init.debug("Initializing prompts...") prompt.init() log.init.debug("Initializing network...") networkmanager.init() log.init.debug("Initializing proxy...") proxy.init() log.init.debug("Initializing readline-bridge...") readline_bridge = readline.ReadlineBridge() objreg.register('readline-bridge', readline_bridge) try: log.init.debug("Initializing sql...") sql.init(os.path.join(standarddir.data(), 'history.sqlite')) log.init.debug("Initializing web history...") history.init(q_app) except sql.SqlEnvironmentError as e: error.handle_fatal_exc(e, args, 'Error initializing SQL', pre_text='Error initializing SQL') sys.exit(usertypes.Exit.err_init) log.init.debug("Initializing command history...") cmdhistory.init() log.init.debug("Initializing crashlog...") if not args.no_err_windows: crash_handler.handle_segfault() log.init.debug("Initializing sessions...") sessions.init(q_app) log.init.debug("Initializing websettings...") websettings.init(args) log.init.debug("Initializing quickmarks...") quickmark_manager = urlmarks.QuickmarkManager(q_app) objreg.register('quickmark-manager', quickmark_manager) log.init.debug("Initializing bookmarks...") bookmark_manager = urlmarks.BookmarkManager(q_app) objreg.register('bookmark-manager', bookmark_manager) log.init.debug("Initializing cookies...") cookie_jar = cookies.CookieJar(q_app) ram_cookie_jar = cookies.RAMCookieJar(q_app) objreg.register('cookie-jar', cookie_jar) objreg.register('ram-cookie-jar', ram_cookie_jar) log.init.debug("Initializing cache...") diskcache = cache.DiskCache(standarddir.cache(), parent=q_app) objreg.register('cache', diskcache) log.init.debug("Initializing downloads...") download_manager = qtnetworkdownloads.DownloadManager(parent=q_app) objreg.register('qtnetwork-download-manager', download_manager) log.init.debug("Initializing Greasemonkey...") greasemonkey.init() log.init.debug("Misc initialization...") macros.init() # Init backend-specific stuff browsertab.init()
def _init_modules(*, args): """Initialize all 'modules' which need to be initialized. Args: args: The argparse namespace. """ log.init.debug("Initializing logging from config...") log.init_from_config(config.val) config.instance.changed.connect(_on_config_changed) log.init.debug("Initializing save manager...") save_manager = savemanager.SaveManager(objects.qapp) objreg.register('save-manager', save_manager) quitter.instance.shutting_down.connect(save_manager.shutdown) configinit.late_init(save_manager) log.init.debug("Checking backend requirements...") backendproblem.init(args=args, save_manager=save_manager) log.init.debug("Initializing prompts...") prompt.init() log.init.debug("Initializing network...") networkmanager.init() log.init.debug("Initializing proxy...") proxy.init() quitter.instance.shutting_down.connect(proxy.shutdown) log.init.debug("Initializing downloads...") downloads.init() quitter.instance.shutting_down.connect(downloads.shutdown) with debug.log_time("init", "Initializing SQL/history"): try: log.init.debug("Initializing web history...") history.init(db_path=pathlib.Path(standarddir.data()) / 'history.sqlite', parent=objects.qapp) except sql.KnownError as e: error.handle_fatal_exc(e, 'Error initializing SQL', pre_text='Error initializing SQL', no_err_windows=args.no_err_windows) sys.exit(usertypes.Exit.err_init) log.init.debug("Initializing command history...") cmdhistory.init() log.init.debug("Initializing websettings...") websettings.init(args) quitter.instance.shutting_down.connect(websettings.shutdown) log.init.debug("Initializing sessions...") sessions.init(objects.qapp) if not args.no_err_windows: crashsignal.crash_handler.display_faulthandler() log.init.debug("Initializing quickmarks...") quickmark_manager = urlmarks.QuickmarkManager(objects.qapp) objreg.register('quickmark-manager', quickmark_manager) log.init.debug("Initializing bookmarks...") bookmark_manager = urlmarks.BookmarkManager(objects.qapp) objreg.register('bookmark-manager', bookmark_manager) log.init.debug("Initializing cookies...") cookies.init(objects.qapp) log.init.debug("Initializing cache...") cache.init(objects.qapp) log.init.debug("Initializing downloads...") qtnetworkdownloads.init() log.init.debug("Initializing Greasemonkey...") greasemonkey.init() log.init.debug("Misc initialization...") macros.init() windowundo.init()