Beispiel #1
0
def early_init(args):
    """Initialize the part of the config which works without a QApplication."""
    configdata.init()

    yaml_config = configfiles.YamlConfig()

    config.instance = config.Config(yaml_config=yaml_config)
    config.val = config.ConfigContainer(config.instance)
    config.key_instance = config.KeyConfig(config.instance)

    for cf in config.change_filters:
        cf.validate()

    configtypes.Font.monospace_fonts = config.val.fonts.monospace

    config_commands = config.ConfigCommands(config.instance,
                                            config.key_instance)
    objreg.register('config-commands', config_commands)

    config_api = None

    try:
        config_api = configfiles.read_config_py()
        # Raised here so we get the config_api back.
        if config_api.errors:
            raise configexc.ConfigFileErrors('config.py', config_api.errors)
    except configexc.ConfigFileErrors as e:
        log.config.exception("Error while loading config.py")
        _init_errors.append(e)

    try:
        if getattr(config_api, 'load_autoconfig', True):
            try:
                config.instance.read_yaml()
            except configexc.ConfigFileErrors as e:
                raise  # caught in outer block
            except configexc.Error as e:
                desc = configexc.ConfigErrorDesc("Error", e)
                raise configexc.ConfigFileErrors('autoconfig.yml', [desc])
    except configexc.ConfigFileErrors as e:
        log.config.exception("Error while loading config.py")
        _init_errors.append(e)

    configfiles.init()

    objects.backend = get_backend(args)
    earlyinit.init_with_backend(objects.backend)
def early_init(args):
    """Initialize the part of the config which works without a QApplication."""
    configdata.init()

    yaml_config = configfiles.YamlConfig()

    config.instance = config.Config(yaml_config=yaml_config)
    config.val = config.ConfigContainer(config.instance)
    config.key_instance = config.KeyConfig(config.instance)
    yaml_config.setParent(config.instance)

    for cf in config.change_filters:
        cf.validate()

    configtypes.Font.monospace_fonts = config.val.fonts.monospace

    config_commands = config.ConfigCommands(config.instance,
                                            config.key_instance)
    objreg.register('config-commands', config_commands)

    config_file = os.path.join(standarddir.config(), 'config.py')

    try:
        if os.path.exists(config_file):
            configfiles.read_config_py(config_file)
        else:
            configfiles.read_autoconfig()
    except configexc.ConfigFileErrors as e:
        log.config.exception("Error while loading {}".format(e.basename))
        global _init_errors
        _init_errors = e

    configfiles.init()

    objects.backend = get_backend(args)

    for opt, val in args.temp_settings:
        try:
            config.instance.set_str(opt, val)
        except configexc.Error as e:
            message.error("set: {} - {}".format(e.__class__.__name__, e))

    if (objects.backend == usertypes.Backend.QtWebEngine and
            config.val.force_software_rendering):
        os.environ['QT_XCB_FORCE_SOFTWARE_OPENGL'] = '1'
 def commands(self, config_stub, keyconf):
     return config.ConfigCommands(config_stub, keyconf)