Пример #1
0
    def _load_config(self):
        """Load config.py as a variable file in a way that the individual
        variables can be overriden on command line as if it was loaded
        explicitly as a variables file.
        """

        source_dir = os.path.dirname(os.path.abspath(__file__))

        # Config file is meant to live in the output directory...
        config_file = os.path.abspath('config.py')
        if not os.path.exists(config_file):
            # ...but look also into the sources to allow RED to do its job
            config_file = os.path.join(source_dir, 'config.py')

        if not os.path.exists(config_file):
            configure = os.path.join(source_dir, 'configure')
            configure = os.path.relpath(configure)
            raise ConfigurationError("Configuration file not found. Forgot to run '{}'?"
                    .format(configure))

        config = Variables()
        config.set_from_file(config_file)

        try:
            global_variables = BuiltIn().get_variables()
            for name in config.as_dict():
                if name in global_variables:
                    config[name] = global_variables[name]
        except RobotNotRunningError:
            # Use the defaults when the IDE queries variables
            pass

        return DotDict(config.as_dict(decoration=False))
Пример #2
0
    def _load_config(self):
        """Load config.py as a variable file in a way that the individual
        variables can be overriden on command line as if it was loaded
        explicitly as a variables file.
        """

        config_dir = os.path.dirname(os.path.abspath(__file__))
        config_file = os.path.join(config_dir, 'config.py')

        config = Variables()
        config.set_from_file(config_file)

        try:
            global_variables = BuiltIn().get_variables()
            for name in config.as_dict():
                if name in global_variables:
                    config[name] = global_variables[name]
        except RobotNotRunningError:
            # Use the defaults when the IDE queries variables
            pass

        return DotDict(config.as_dict(decoration=False))