How to use the platformio.app.get_setting 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 / tests / test_maintenance.py View on Github external
def test_check_platform_updates(clirunner, isolated_pio_home,
                                validate_cliresult):
    # install obsolete platform
    result = clirunner.invoke(cli_pio, ["platform", "install", "native"])
    validate_cliresult(result)
    manifest_path = isolated_pio_home.join("platforms", "native",
                                           "platform.json")
    manifest = json.loads(manifest_path.read())
    manifest['version'] = "0.0.0"
    manifest_path.write(json.dumps(manifest))
    # reset cached manifests
    PlatformManager().cache_reset()

    # reset check time
    interval = int(app.get_setting("check_platforms_interval")) * 3600 * 24
    last_check = {"platforms_update": time() - interval - 1}
    app.set_state_item("last_check", last_check)

    result = clirunner.invoke(cli_pio, ["platform", "list"])
    validate_cliresult(result)
    assert "There are the new updates for platforms (native)" in result.output
github bq / bitbloq-offline / app / res / web2board / darwin / Web2Board.app / Contents / Resources / platformio / commands / lib.py View on Github external
assert isinstance(data, dict)
    query = []
    for key in data.keys():
        if key in ("authors", "frameworks", "platforms", "keywords"):
            values = data[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], value))
        elif isinstance(data[key], basestring):
            query.append('+"%s"' % data[key])

    result = get_api_result("/lib/search", dict(query=" ".join(query)))
    assert result['total'] > 0

    if result['total'] == 1 or not app.get_setting("enable_prompts"):
        ctx.invoke(lib_install, libid=[result['items'][0]['id']])
    else:
        click.secho(
            "Conflict: More than one dependent libraries have been found "
            "by request %s:" % json.dumps(data), fg="red")

        echo_liblist_header()
        for item in result['items']:
            echo_liblist_item(item)

        deplib_id = click.prompt(
            "Please choose one dependent library ID",
            type=click.Choice([str(i['id']) for i in result['items']]))
        ctx.invoke(lib_install, libid=[int(deplib_id)])
github bq / web2board / src / platformio / platforms / base.py View on Github external
def _install_default_packages(self):
        installed_platforms = PlatformFactory.get_platforms(
            installed=True).keys()

        if (self.get_type() in installed_platforms and
                    set(self.get_default_packages()) <=
                    set(self.get_installed_packages())):
            return True

        if (not app.get_setting("enable_prompts") or
                    self.get_type() in installed_platforms or
                click.confirm(
                        "The platform '%s' has not been installed yet. "
                        "Would you like to install it now?" % self.get_type())):
            return self.install()
        else:
            raise exception.PlatformNotInstalledYet(self.get_type())
github platformio / platformio-core / platformio / commands / settings.py View on Github external
def settings_get(name):
    tabular_data = []
    for key, options in sorted(app.DEFAULT_SETTINGS.items()):
        if name and name != key:
            continue
        raw_value = app.get_setting(key)
        formatted_value = format_value(raw_value)

        if raw_value != options["value"]:
            default_formatted_value = format_value(options["value"])
            formatted_value += "%s" % (
                "\n" if len(default_formatted_value) > 10 else " "
            )
            formatted_value += "[%s]" % click.style(
                default_formatted_value, fg="yellow"
            )

        tabular_data.append(
            (click.style(key, fg="cyan"), formatted_value, options["description"])
        )

    click.echo(
github platformio / platformio-core / platformio / managers / platform.py View on Github external
def run(self, variables, targets, silent, verbose):
        assert isinstance(variables, dict)
        assert isinstance(targets, list)

        config = ProjectConfig.get_instance(variables['project_config'])
        options = config.items(env=variables['pioenv'], as_dict=True)
        if "framework" in options:
            # support PIO Core 3.0 dev/platforms
            options['pioframework'] = options['framework']
        self.configure_default_packages(options, targets)
        self.install_packages(silent=True)

        self.silent = silent
        self.verbose = verbose or app.get_setting("force_verbose")

        if "clean" in targets:
            targets = ["-c", "."]

        variables['platform_manifest'] = self.manifest_path

        if "build_script" not in variables:
            variables['build_script'] = self.get_build_script()
        if not isfile(variables['build_script']):
            raise exception.BuildScriptNotFound(variables['build_script'])

        result = self._run_scons(variables, targets)
        assert "returncode" in result

        return result
github bq / bitbloq-offline / app / res / web2board / darwin / Web2Board.app / Contents / Resources / platformio / maintenance.py View on Github external
def check_platformio_upgrade():
    last_check = app.get_state_item("last_check", {})
    interval = int(app.get_setting("check_platformio_interval")) * 3600 * 24
    if (time() - interval) < last_check.get("platformio_upgrade", 0):
        return

    last_check['platformio_upgrade'] = int(time())
    app.set_state_item("last_check", last_check)

    latest_version = get_latest_version()
    if (latest_version == __version__ or
            Upgrader.version_to_int(latest_version) <
            Upgrader.version_to_int(__version__)):
        return

    terminal_width, _ = click.get_terminal_size()

    click.echo("")
    click.echo("*" * terminal_width)
github bq / bitbloq-offline / app / res / web2board / darwin / Web2Board.app / Contents / Resources / 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)

    outdated_items = []
    if what == "platforms":
        for platform in PlatformFactory.get_platforms(installed=True).keys():
            p = PlatformFactory.newPlatform(platform)
            if p.is_outdated():
                outdated_items.append(platform)
    elif what == "libraries":
        lm = LibraryManager()
        outdated_items = lm.get_outdated()
github platformio / platformio-core / platformio / managers / platform.py View on Github external
def __init__(self, package_dir=None, repositories=None):
        if not repositories:
            repositories = [
                "https://dl.bintray.com/platformio/dl-platforms/manifest.json",
                "{0}://dl.platformio.org/platforms/manifest.json".format(
                    "https" if app.get_setting("enable_ssl") else "http")
            ]
        BasePkgManager.__init__(self, package_dir
                                or get_project_platforms_dir(), repositories)
github platformio / platformio-core / platformio / maintenance.py View on Github external
if any(conds):
            outdated_items.append(manifest["name"])

    if not outdated_items:
        return

    terminal_width, _ = click.get_terminal_size()

    click.echo("")
    click.echo("*" * terminal_width)
    click.secho(
        "There are the new updates for %s (%s)" % (what, ", ".join(outdated_items)),
        fg="yellow",
    )

    if not app.get_setting("auto_update_" + what):
        click.secho("Please update them via ", fg="yellow", nl=False)
        click.secho(
            "`platformio %s update`"
            % ("lib --global" if what == "libraries" else "platform"),
            fg="cyan",
            nl=False,
        )
        click.secho(" command.\n", fg="yellow")
        click.secho(
            "If you want to manually check for the new versions "
            "without updating, please use ",
            fg="yellow",
            nl=False,
        )
        click.secho(
            "`platformio %s update --dry-run`"