How to use the platformio.managers.platform.PlatformManager function in platformio

To help you get started, we’ve selected a few platformio 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 platformio / platformio-core / platformio / commands / platform.py View on Github external
def _get_registry_platforms():
    platforms = util.get_api_result("/platforms", cache_valid="7d")
    pm = PlatformManager()
    for platform in platforms or []:
        platform['versions'] = pm.get_all_repo_versions(platform['name'])
    return platforms
github platformio / platformio-core / platformio / commands / platform.py View on Github external
def platform_uninstall(platforms):
    pm = PlatformManager()
    for platform in platforms:
        if pm.uninstall(platform):
            click.secho("The platform '%s' has been successfully "
                        "uninstalled!" % platform,
                        fg="green")
github platformio / platformio-core / platformio / commands / platform.py View on Github external
data = dict(name=_data['name'],
                title=_data['title'],
                description=_data['description'],
                homepage=_data['homepage'],
                repository=_data['repository'],
                url=_data['url'],
                license=_data['license'],
                forDesktop=_data['forDesktop'],
                frameworks=_data['frameworks'],
                packages=_data['packages'],
                versions=_data['versions'])

    if with_boards:
        data['boards'] = [
            board for board in PlatformManager().get_registered_boards()
            if board['platform'] == _data['name']
        ]

    return data
github platformio / platformio-core / platformio / commands / platform.py View on Github external
def _get_registry_platforms():
    platforms = util.get_api_result("/platforms", cache_valid="7d")
    pm = PlatformManager()
    for platform in platforms or []:
        platform['versions'] = pm.get_all_repo_versions(platform['name'])
    return platforms
github platformio / platformio-core / platformio / maintenance.py View on Github external
def check_internal_updates(ctx, what):
    last_check = app.get_state_item("last_check", {})
    interval = int(app.get_setting("check_%s_interval" % what)) * 3600 * 24
    if (time() - interval) < last_check.get(what + "_update", 0):
        return

    last_check[what + "_update"] = int(time())
    app.set_state_item("last_check", last_check)

    util.internet_on(raise_exception=True)

    pm = PlatformManager() if what == "platforms" else LibraryManager()
    outdated_items = []
    for manifest in pm.get_installed():
        if manifest["name"] in outdated_items:
            continue
        conds = [
            pm.outdated(manifest["__pkg_dir"]),
            what == "platforms"
            and PlatformFactory.newPlatform(
                manifest["__pkg_dir"]
            ).are_outdated_packages(),
        ]
        if any(conds):
            outdated_items.append(manifest["name"])

    if not outdated_items:
        return
github platformio / platformio-core / platformio / commands / boards.py View on Github external
def _get_boards(installed=False):
    pm = PlatformManager()
    return pm.get_installed_boards() if installed else pm.get_all_boards()
github platformio / platformio-core / platformio / commands / platform.py View on Github external
def platform_list(json_output):
    platforms = []
    pm = PlatformManager()
    for manifest in pm.get_installed():
        platforms.append(
            _get_installed_platform_data(manifest['__pkg_dir'],
                                         with_boards=False,
                                         expose_packages=False))

    platforms = sorted(platforms, key=lambda manifest: manifest['name'])
    if json_output:
        click.echo(dump_json_to_unicode(platforms))
    else:
        _print_platforms(platforms)
github platformio / platformio-core / platformio / commands / platform.py View on Github external
@cli.command("list", short_help="List installed development platforms")
@click.option("--json-output", is_flag=True)
def platform_list(json_output):
    platforms = []
    pm = PlatformManager()
    for manifest in pm.get_installed():
        platforms.append(
            _get_installed_platform_data(manifest['__pkg_dir'],
                                         with_boards=False,
                                         expose_packages=False))

    platforms = sorted(platforms, key=lambda manifest: manifest['name'])
    if json_output:
        click.echo(dump_json_to_unicode(platforms))
    else:
        _print_platforms(platforms)
github platformio / platformio-core / platformio / managers / platform.py View on Github external
def cleanup_packages(self, names):
        self.cache_reset()
        deppkgs = {}
        for manifest in PlatformManager().get_installed():
            p = PlatformFactory.newPlatform(manifest['__pkg_dir'])
            for pkgname, pkgmanifest in p.get_installed_packages().items():
                if pkgname not in deppkgs:
                    deppkgs[pkgname] = set()
                deppkgs[pkgname].add(pkgmanifest['version'])

        pm = PackageManager(get_project_packages_dir())
        for manifest in pm.get_installed():
            if manifest['name'] not in names:
                continue
            if (manifest['name'] not in deppkgs
                    or manifest['version'] not in deppkgs[manifest['name']]):
                try:
                    pm.uninstall(manifest['__pkg_dir'], after_update=True)
                except exception.UnknownPackage:
                    pass