How to use the platformio.util.get_api_result 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 / managers / lib.py View on Github external
if not silent:
            click.echo("Looking for %s library in registry" %
                       click.style(filters['name'], fg="cyan"))
        query = []
        for key in filters:
            if key not in ("name", "authors", "frameworks", "platforms"):
                continue
            values = filters[key]
            if not isinstance(values, list):
                values = [v.strip() for v in values.split(",") if v]
            for value in values:
                query.append('%s:"%s"' %
                             (key[:-1] if key.endswith("s") else key, value))

        lib_info = None
        result = util.get_api_result("/v2/lib/search",
                                     dict(query=" ".join(query)),
                                     cache_valid="1h")
        if result['total'] == 1:
            lib_info = result['items'][0]
        elif result['total'] > 1:
            if silent and not interactive:
                lib_info = result['items'][0]
            else:
                click.secho("Conflict: More than one library has been found "
                            "by request %s:" % json.dumps(filters),
                            fg="yellow",
                            err=True)
                from platformio.commands.lib import print_lib_item
                for item in result['items']:
                    print_lib_item(item)
github platformio / platformio-core / platformio / commands / lib.py View on Github external
if int(result["page"]) * int(result["perpage"]) >= int(result["total"]):
            break

        if noninteractive:
            click.echo()
            click.secho(
                "Loading next %d libraries... Press Ctrl+C to stop!"
                % result["perpage"],
                fg="yellow",
            )
            click.echo()
            time.sleep(5)
        elif not click.confirm("Show next libraries?"):
            break
        result = util.get_api_result(
            "/v2/lib/search",
            {"query": " ".join(query), "page": int(result["page"]) + 1},
            cache_valid="1d",
        )
github platformio / platformio-core / platformio / managers / lib.py View on Github external
def get_latest_repo_version(self, name, requirements, silent=False):
        item = self.max_satisfying_repo_version(
            util.get_api_result("/lib/info/%d" % self.search_lib_id(
                {
                    "name": name,
                    "requirements": requirements
                }, silent=silent),
                                cache_valid="1h")['versions'], requirements)
        return item['name'] if item else None
github platformio / platformio-core / platformio / managers / platform.py View on Github external
def get_registered_boards():
        return util.get_api_result("/boards", cache_valid="7d")
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 / lib.py View on Github external
def lib_stats(json_output):
    result = util.get_api_result("/lib/stats", cache_valid="1h")

    if json_output:
        return click.echo(dump_json_to_unicode(result))

    for key in ("updated", "added"):
        tabular_data = [
            (
                click.style(item["name"], fg="cyan"),
                time.strftime("%c", util.parse_date(item["date"])),
                "https://platformio.org/lib/show/%s/%s"
                % (item["id"], quote(item["name"])),
            )
            for item in result.get(key, [])
        ]
        table = tabulate(
            tabular_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 / managers / platform.py View on Github external
def get_registered_boards():
        return util.get_api_result("/boards", cache_valid="7d")