Exemplo n.º 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))
Exemplo n.º 2
0
def import_varfile(varfile_path, args):
    temp = RobotVariables()
    try:
        temp.set_from_file(varfile_path, args)
    except SystemExit:
        raise DataError('Variable file import failed')
    return [(name, _format_value(value), varfile_path) for (name, value) in temp.items()]
Exemplo n.º 3
0
def set_from_file(queue, varfile_path, args):
    try:
        temp = RobotVariables()
        temp.set_from_file(varfile_path, args)
        for (name, value) in temp.items():
            queue.put((name, value, varfile_path))
    except DataError, e:
        queue.put((e,))
def import_varfile(varfile_path, args):
    temp = RobotVariables()
    try:
        temp.set_from_file(varfile_path, args)
    except SystemExit:
        raise DataError('Variable file import failed')
    return [(name, _format_value(value), varfile_path)
            for (name, value) in temp.items()]
Exemplo n.º 5
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))
Exemplo n.º 6
0
 def set_from_file(self, varfile_path, args):
     temp = RobotVariables()
     temp.set_from_file(varfile_path, args)
     for (name, value) in temp.items():
         self.set(name, value, varfile_path)