Exemple #1
0
def update_pi4home_core_repo():
    if CONF_REPOSITORY not in CORE.pi4home_core_version:
        return

    if CONF_BRANCH not in CORE.pi4home_core_version:
        # Git commit hash or tag cannot be updated
        return

    pi4home_core_path = CORE.relative_piolibdeps_path('pi4home-core')

    rc, _, _ = run_system_command('git', '-C', pi4home_core_path, '--help')
    if rc != 0:
        # git not installed or repo not downloaded yet
        return
    rc, _, _ = run_system_command('git', '-C', pi4home_core_path, 'diff-index',
                                  '--quiet', 'HEAD', '--')
    if rc != 0:
        # local changes, cannot update
        _LOGGER.warning(
            "Local changes in pi4home-core copy from git. Will not auto-update."
        )
        return
    _LOGGER.info("Updating pi4home-core copy from git (%s)", pi4home_core_path)
    rc, stdout, _ = run_system_command('git', '-c', 'color.ui=always', '-C',
                                       pi4home_core_path, 'pull', '--stat')
    if rc != 0:
        _LOGGER.warning("Couldn't auto-update local git copy of pi4home-core.")
        return
    if IS_PY3:
        stdout = stdout.decode('utf-8', 'backslashreplace')
    safe_print(stdout.strip())
Exemple #2
0
def clean_build():
    pioenvs = CORE.relative_pioenvs_path()
    if os.path.isdir(pioenvs):
        _LOGGER.info("Deleting %s", pioenvs)
        shutil.rmtree(pioenvs)
    piolibdeps = CORE.relative_piolibdeps_path()
    if os.path.isdir(piolibdeps):
        _LOGGER.info("Deleting %s", piolibdeps)
        shutil.rmtree(piolibdeps)
Exemple #3
0
def run_platformio_cli(*args, **kwargs):
    os.environ["PLATFORMIO_FORCE_COLOR"] = "true"
    os.environ["PLATFORMIO_BUILD_DIR"] = os.path.abspath(CORE.relative_pioenvs_path())
    os.environ["PLATFORMIO_LIBDEPS_DIR"] = os.path.abspath(CORE.relative_piolibdeps_path())
    cmd = ['platformio'] + list(args)

    if os.environ.get('PI4HOME_USE_SUBPROCESS') is None:
        import platformio.__main__
        return run_external_command(platformio.__main__.main,
                                    *cmd, **kwargs)

    return run_external_process(*cmd, **kwargs)