How to use the west.configuration.update_config function in west

To help you get started, we’ve selected a few west examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github zephyrproject-rtos / west / tests / test_config.py View on Github external
def test_delete_local_with_topdir():
    # Test LOCAL-only delete with specified topdir.
    config.update_config('pytest', 'key', 'system', configfile=SYSTEM)
    config.update_config('pytest', 'key', 'global', configfile=GLOBAL)
    config.update_config('pytest', 'key', 'local', configfile=LOCAL)
    assert cfg(f=SYSTEM)['pytest']['key'] == 'system'
    assert cfg(f=GLOBAL)['pytest']['key'] == 'global'
    assert cfg(f=LOCAL)['pytest']['key'] == 'local'
    config.delete_config('pytest', 'key', configfile=LOCAL)
    assert cfg(f=SYSTEM)['pytest']['key'] == 'system'
    assert cfg(f=GLOBAL)['pytest']['key'] == 'global'
    assert 'pytest' not in cfg(f=LOCAL)
github zephyrproject-rtos / west / tests / test_config.py View on Github external
def test_delete_local_with_topdir():
    # Test LOCAL-only delete with specified topdir.
    config.update_config('pytest', 'key', 'system', configfile=SYSTEM)
    config.update_config('pytest', 'key', 'global', configfile=GLOBAL)
    config.update_config('pytest', 'key', 'local', configfile=LOCAL)
    assert cfg(f=SYSTEM)['pytest']['key'] == 'system'
    assert cfg(f=GLOBAL)['pytest']['key'] == 'global'
    assert cfg(f=LOCAL)['pytest']['key'] == 'local'
    config.delete_config('pytest', 'key', configfile=LOCAL)
    assert cfg(f=SYSTEM)['pytest']['key'] == 'system'
    assert cfg(f=GLOBAL)['pytest']['key'] == 'global'
    assert 'pytest' not in cfg(f=LOCAL)
github zephyrproject-rtos / west / tests / test_config.py View on Github external
def test_delete_local_with_topdir():
    # Test LOCAL-only delete with specified topdir.
    config.update_config('pytest', 'key', 'system', configfile=SYSTEM)
    config.update_config('pytest', 'key', 'global', configfile=GLOBAL)
    config.update_config('pytest', 'key', 'local', configfile=LOCAL)
    assert cfg(f=SYSTEM)['pytest']['key'] == 'system'
    assert cfg(f=GLOBAL)['pytest']['key'] == 'global'
    assert cfg(f=LOCAL)['pytest']['key'] == 'local'
    config.delete_config('pytest', 'key', configfile=LOCAL)
    assert cfg(f=SYSTEM)['pytest']['key'] == 'system'
    assert cfg(f=GLOBAL)['pytest']['key'] == 'global'
    assert 'pytest' not in cfg(f=LOCAL)
github zephyrproject-rtos / west / tests / test_config.py View on Github external
def test_config_system_precedence():
    # Test precedence rules, including system level.

    config.update_config('pytest', 'key', 'sys', configfile=SYSTEM)
    assert cfg(f=SYSTEM)['pytest']['key'] == 'sys'
    assert cfg(f=ALL)['pytest']['key'] == 'sys'

    config.update_config('pytest', 'key', 'glb', configfile=GLOBAL)
    assert cfg(f=SYSTEM)['pytest']['key'] == 'sys'
    assert cfg(f=GLOBAL)['pytest']['key'] == 'glb'
    assert cfg(f=ALL)['pytest']['key'] == 'glb'

    config.update_config('pytest', 'key', 'lcl', configfile=LOCAL)
    assert cfg(f=SYSTEM)['pytest']['key'] == 'sys'
    assert cfg(f=GLOBAL)['pytest']['key'] == 'glb'
    assert cfg(f=LOCAL)['pytest']['key'] == 'lcl'
    assert cfg(f=ALL)['pytest']['key'] == 'lcl'
github zephyrproject-rtos / west / tests / test_config.py View on Github external
def test_delete_local():
    # Test LOCAL-only delete.
    config.update_config('pytest', 'key', 'system', configfile=SYSTEM)
    config.update_config('pytest', 'key', 'global', configfile=GLOBAL)
    config.update_config('pytest', 'key', 'local', configfile=LOCAL)
    assert cfg(f=SYSTEM)['pytest']['key'] == 'system'
    assert cfg(f=GLOBAL)['pytest']['key'] == 'global'
    assert cfg(f=LOCAL)['pytest']['key'] == 'local'
    config.delete_config('pytest', 'key', configfile=LOCAL)
    assert cfg(f=SYSTEM)['pytest']['key'] == 'system'
    assert cfg(f=GLOBAL)['pytest']['key'] == 'global'
    assert 'pytest' not in cfg(f=LOCAL)
github zephyrproject-rtos / west / tests / test_config.py View on Github external
def test_local_creation():
    # Like test_system_creation, for local config options.

    assert not os.path.isfile(config._location(SYSTEM))
    assert not os.path.isfile(config._location(GLOBAL))
    assert not os.path.isfile(config._location(LOCAL))

    config.update_config('pytest', 'key', 'val', configfile=LOCAL)

    assert not os.path.isfile(config._location(SYSTEM))
    assert not os.path.isfile(config._location(GLOBAL))
    assert os.path.isfile(config._location(LOCAL))
    assert cfg(f=ALL)['pytest']['key'] == 'val'
    assert 'pytest' not in cfg(f=SYSTEM)
    assert 'pytest' not in cfg(f=GLOBAL)
    assert cfg(f=LOCAL)['pytest']['key'] == 'val'
github zephyrproject-rtos / west / tests / test_config.py View on Github external
def test_delete_local_one():
    # Test LOCAL-only delete of one option doesn't affect the other.
    config.update_config('pytest', 'key1', 'foo', configfile=LOCAL)
    config.update_config('pytest', 'key2', 'bar', configfile=LOCAL)
    config.delete_config('pytest', 'key1', configfile=LOCAL)
    assert 'pytest' in cfg(f=LOCAL)
    assert cfg(f=LOCAL)['pytest']['key2'] == 'bar'
github zephyrproject-rtos / west / tests / test_config.py View on Github external
system = pathlib.Path(config._location(SYSTEM))
    glbl = pathlib.Path(config._location(GLOBAL))
    local = pathlib.Path(config._location(LOCAL))

    topdir = pathlib.Path(os.getcwd()) / 'test-topdir'
    topdir_west = topdir / '.west'
    assert not topdir_west.exists()
    topdir_west.mkdir(parents=True)
    topdir_config = topdir_west / 'config'

    assert not system.exists()
    assert not glbl.exists()
    assert not local.exists()
    assert not topdir_config.exists()

    config.update_config('pytest', 'key', 'val', configfile=LOCAL,
                         topdir=str(topdir))

    assert not system.exists()
    assert not glbl.exists()
    assert not local.exists()
    assert topdir_config.exists()

    assert cfg(f=ALL, topdir=str(topdir))['pytest']['key'] == 'val'
    assert 'pytest' not in cfg(f=SYSTEM)
    assert 'pytest' not in cfg(f=GLOBAL)
    assert cfg(f=LOCAL, topdir=str(topdir))['pytest']['key'] == 'val'
github zephyrproject-rtos / west / src / west / app / main.py View on Github external
# At some point, we need a more flexible way to set environment
        # variables based on manifest contents, but this is good enough
        # to get started with and to ask for wider testing.
        zb_env = os.environ.get('ZEPHYR_BASE')
        zb_prefer = config.config.get('zephyr', 'base-prefer',
                                      fallback=None)
        rel_zb_config = config.config.get('zephyr', 'base', fallback=None)
        if rel_zb_config is None:
            projects = None
            try:
                projects = manifest.get_projects(['zephyr'])
            except ValueError:
                pass
            if projects:
                zephyr = projects[0]
                config.update_config('zephyr', 'base', zephyr.path)
                rel_zb_config = zephyr.path
        if rel_zb_config is not None:
            zb_config = Path(topdir) / rel_zb_config
        else:
            zb_config = None

        if zb_prefer == 'env' and zb_env is not None:
            zb = zb_env
            zb_origin = 'env'
        elif zb_prefer == 'configfile' and zb_config is not None:
            zb = str(zb_config)
            zb_origin = 'configfile'
        elif zb_env is not None:
            zb = zb_env
            zb_origin = 'env'
            try: