Exemplo n.º 1
0
def platforms_search(query, json_output):

    data = []
    platforms = PlatformFactory.get_platforms().keys()
    platforms.sort()
    for platform in platforms:
        p = PlatformFactory.newPlatform(platform)
        type_ = p.get_type()
        description = p.get_description()

        if query == "all":
            query = ""

        search_data = "%s %s %s" % (type_, description, p.get_packages())
        if query and query.lower() not in search_data.lower():
            continue

        data.append({
            "type": type_,
            "description": description,
            "packages": p.get_packages()
        })

    if json_output:
        click.echo(json.dumps(data))
    else:
        terminal_width, _ = click.get_terminal_size()
        for item in data:
            click.secho(item['type'], fg="cyan", nl=False)
            click.echo(" (available packages: %s)" % ", ".join(
                item.get("packages").keys()))
            click.echo("-" * terminal_width)
            click.echo(item['description'])
            click.echo()
Exemplo n.º 2
0
def platforms_search(query, json_output):

    data = []
    platforms = PlatformFactory.get_platforms().keys()
    platforms.sort()
    for platform in platforms:
        p = PlatformFactory.newPlatform(platform)
        type_ = p.get_type()
        description = p.get_description()

        if query == "all":
            query = ""

        search_data = "%s %s %s" % (type_, description, p.get_packages())
        if query and query.lower() not in search_data.lower():
            continue

        data.append({
            "type": type_,
            "description": description,
            "packages": p.get_packages()
        })

    if json_output:
        click.echo(json.dumps(data))
    else:
        terminal_width, _ = click.get_terminal_size()
        for item in data:
            click.secho(item['type'], fg="cyan", nl=False)
            click.echo(" (available packages: %s)" % ", ".join(
                item.get("packages").keys()))
            click.echo("-" * terminal_width)
            click.echo(item['description'])
            click.echo()
Exemplo n.º 3
0
def cli():

    for platform in PackageManager.get_installed().keys():
        echo("\nPlatform %s" % style(platform, fg="cyan"))
        echo("--------")
        p = PlatformFactory().newPlatform(platform)
        p.update()
Exemplo n.º 4
0
def _autoinstall_platform(ctx, platform, targets):
    installed_platforms = PlatformFactory.get_platforms(installed=True).keys()
    cmd_options = {}
    p = PlatformFactory.newPlatform(platform)

    if "uploadlazy" in targets:
        upload_tools = p.pkg_aliases_to_names(["uploader"])

        # platform without uploaders
        if not upload_tools and platform in installed_platforms:
            return
        # uploaders are already installed
        if set(upload_tools) <= set(p.get_installed_packages()):
            return

        cmd_options["skip_default_package"] = True
        if upload_tools:
            cmd_options["with_package"] = ["uploader"]

    elif platform in installed_platforms and set(p.get_default_packages()) <= set(p.get_installed_packages()):
        return

    if not app.get_setting("enable_prompts") or click.confirm(
        "The platform '%s' has not been installed yet. " "Would you like to install it now?" % platform
    ):
        ctx.invoke(cmd_platforms_install, platforms=[platform], **cmd_options)
Exemplo n.º 5
0
def _autoinstall_platform(ctx, platform, targets):
    installed_platforms = PlatformFactory.get_platforms(installed=True).keys()
    cmd_options = {}
    p = PlatformFactory.newPlatform(platform)

    if "uploadlazy" in targets:
        upload_tools = p.pkg_aliases_to_names(["uploader"])

        # platform without uploaders
        if not upload_tools and platform in installed_platforms:
            return
        # uploaders are already installed
        if set(upload_tools) <= set(p.get_installed_packages()):
            return

        cmd_options['skip_default_package'] = True
        if upload_tools:
            cmd_options['with_package'] = ["uploader"]

    elif (platform in installed_platforms and
          set(p.get_default_packages()) <= set(p.get_installed_packages())):
        return

    if (not app.get_setting("enable_prompts")
            or click.confirm("The platform '%s' has not been installed yet. "
                             "Would you like to install it now?" % platform)):
        ctx.invoke(cmd_platforms_install, platforms=[platform], **cmd_options)
Exemplo n.º 6
0
def generate_framework(type_, data):
    print "Processing framework: %s" % type_
    lines = []

    lines.append(".. _framework_%s:" % type_)
    lines.append("")

    _title = "Framework ``%s``" % type_
    lines.append(_title)
    lines.append("=" * len(_title))
    lines.append(data['description'])
    lines.append("""
For more detailed information please visit `vendor site <%s>`_.
""" % data['url'])

    lines.append(".. contents::")

    lines.append("""
Platforms
---------
.. list-table::
    :header-rows:  1

    * - Name
      - Description""")

    for platform in sorted(PlatformFactory.get_platforms().keys()):
        if not is_compat_platform_and_framework(platform, type_):
            continue
        p = PlatformFactory.newPlatform(platform)
        lines.append("""
    * - :ref:`platform_{type_}`
      - {description}""".format(
            type_=platform,
            description=p.get_description()))

    lines.append("""
Boards
------

.. note::
    * You can list pre-configured boards by :ref:`cmd_boards` command or
      `PlatformIO Boards Explorer <http://platformio.org/#!/boards>`_
    * For more detailed ``board`` information please scroll tables below by horizontal.
""")

    vendors = {}
    for board, data in util.get_boards().items():
        frameworks = data['frameworks']
        vendor = data['vendor']
        if type_ in frameworks:
            if vendor in vendors:
                vendors[vendor].append({board: data})
            else:
                vendors[vendor] = [{board: data}]
    for vendor, boards in sorted(vendors.iteritems()):
        lines.append(str(vendor))
        lines.append("~" * len(vendor))
        lines.append(generate_boards(boards))
    return "\n".join(lines)
Exemplo n.º 7
0
def _run_environment(ctx, name, options, targets, upload_port):
    variables = ["PIOENV=" + name]
    if upload_port:
        variables.append("UPLOAD_PORT=%s" % upload_port)
    for k, v in options.items():
        k = k.upper()
        if k == "TARGETS" or (k == "UPLOAD_PORT" and upload_port):
            continue
        variables.append("%s=%s" % (k.upper(), v))

    envtargets = []
    if targets:
        envtargets = [t for t in targets]
    elif "targets" in options:
        envtargets = options['targets'].split()

    if "platform" not in options:
        raise exception.UndefinedEnvPlatform(name)
    platform = options['platform']

    telemetry.on_run_environment(options, envtargets)

    installed_platforms = PlatformFactory.get_platforms(
        installed=True).keys()
    if (platform not in installed_platforms and (
            not app.get_setting("enable_prompts") or
            click.confirm("The platform '%s' has not been installed yet. "
                          "Would you like to install it now?" % platform))):
        ctx.invoke(cmd_install, platforms=[platform])

    p = PlatformFactory.newPlatform(platform)
    return p.run(variables, envtargets)
Exemplo n.º 8
0
def _run_environment(ctx, name, options, targets, upload_port):
    variables = ["PIOENV=" + name]
    if upload_port:
        variables.append("UPLOAD_PORT=%s" % upload_port)
    for k, v in options.items():
        k = k.upper()
        if k == "TARGETS" or (k == "UPLOAD_PORT" and upload_port):
            continue
        variables.append("%s=%s" % (k.upper(), v))

    envtargets = []
    if targets:
        envtargets = [t for t in targets]
    elif "targets" in options:
        envtargets = options['targets'].split()

    if "platform" not in options:
        raise exception.UndefinedEnvPlatform(name)
    platform = options['platform']

    telemetry.on_run_environment(options, envtargets)

    installed_platforms = PlatformFactory.get_platforms(installed=True).keys()
    if (platform not in installed_platforms and
        (not app.get_setting("enable_prompts")
         or click.confirm("The platform '%s' has not been installed yet. "
                          "Would you like to install it now?" % platform))):
        ctx.invoke(cmd_install, platforms=[platform])

    p = PlatformFactory.newPlatform(platform)
    return p.run(variables, envtargets)
Exemplo n.º 9
0
def cli(platforms, with_package, without_package, skip_default_package):

    for platform in platforms:
        p = PlatformFactory().newPlatform(platform)
        if p.install(with_package, without_package, skip_default_package):
            secho("The platform '%s' has been successfully installed!" %
                  platform, fg="green")
Exemplo n.º 10
0
def platforms_show(ctx, platform):

    installed_platforms = PlatformFactory.get_platforms(
        installed=True).keys()

    if platform not in installed_platforms:
        if (not app.get_setting("enable_prompts") or
                click.confirm("The platform '%s' has not been installed yet. "
                              "Would you like to install it now?" % platform)):
            ctx.invoke(platforms_install, platforms=[platform])
        else:
            raise PlatformNotInstalledYet(platform)

    p = PlatformFactory.newPlatform(platform)
    click.echo("{name:<20} - {description} [ {url} ]".format(
        name=click.style(p.get_type(), fg="cyan"),
        description=p.get_description(), url=p.get_vendor_url()))

    installed_packages = PackageManager.get_installed()
    for name in p.get_installed_packages():
        data = installed_packages[name]
        pkgalias = p.get_package_alias(name)
        click.echo("----------")
        click.echo("Package: %s" % click.style(name, fg="yellow"))
        if pkgalias:
            click.echo("Alias: %s" % pkgalias)
        click.echo("Version: %d" % int(data['version']))
        click.echo("Installed: %s" % datetime.fromtimestamp(
            data['time']).strftime("%Y-%m-%d %H:%M:%S"))
Exemplo n.º 11
0
def platforms_show(ctx, platform):

    installed_platforms = PlatformFactory.get_platforms(
        installed=True).keys()

    if platform not in installed_platforms:
        if (not app.get_setting("enable_prompts") or
                click.confirm("The platform '%s' has not been installed yet. "
                              "Would you like to install it now?" % platform)):
            ctx.invoke(platforms_install, platforms=[platform])
        else:
            raise PlatformNotInstalledYet(platform)

    p = PlatformFactory.newPlatform(platform)
    click.echo("{name:<20} - {description} [ {url} ]".format(
        name=click.style(p.get_type(), fg="cyan"),
        description=p.get_description(), url=p.get_vendor_url()))

    installed_packages = PackageManager.get_installed()
    for name in p.get_installed_packages():
        data = installed_packages[name]
        pkgalias = p.get_pkg_alias(name)
        click.echo("----------")
        click.echo("Package: %s" % click.style(name, fg="yellow"))
        if pkgalias:
            click.echo("Alias: %s" % pkgalias)
        click.echo("Version: %d" % int(data['version']))
        click.echo("Installed: %s" % datetime.fromtimestamp(
            data['time']).strftime("%Y-%m-%d %H:%M:%S"))
Exemplo n.º 12
0
def cli(platforms, with_package, without_package, skip_default_package):

    for platform in platforms:
        p = PlatformFactory().newPlatform(platform)
        if p.install(with_package, without_package, skip_default_package):
            secho("The platform '%s' has been successfully installed!" %
                  platform,
                  fg="green")
Exemplo n.º 13
0
def cli():

    installed_platforms = PlatformFactory.get_platforms(installed=True).keys()
    installed_platforms.sort()

    for platform in installed_platforms:
        click.echo("\nPlatform %s" % click.style(platform, fg="cyan"))
        click.echo("--------")
        p = PlatformFactory.newPlatform(platform)
        p.update()
Exemplo n.º 14
0
def cli(platforms):

    for platform in platforms:

        if platform not in PackageManager.get_installed():
            raise PlatformNotInstalledYet(platform)

        p = PlatformFactory().newPlatform(platform)
        if p.uninstall():
            secho("The platform '%s' has been successfully "
                  "uninstalled!" % platform, fg="green")
Exemplo n.º 15
0
def cli(platforms):

    for platform in platforms:

        if platform not in PackageManager.get_installed():
            raise PlatformNotInstalledYet(platform)

        p = PlatformFactory().newPlatform(platform)
        if p.uninstall():
            secho("The platform '%s' has been successfully "
                  "uninstalled!" % platform,
                  fg="green")
Exemplo n.º 16
0
def cli(query):
    for platform in get_platforms():
        p = PlatformFactory().newPlatform(platform)
        name = p.get_name()
        shinfo = p.get_short_info()

        search_data = "%s %s" % (name, shinfo)
        if query != "all" and query.lower() not in search_data.lower():
            continue

        echo("{name:<20} - {info}".format(name=style(name, fg="cyan"),
                                          info=shinfo))
Exemplo n.º 17
0
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()

    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" if what == "libraries" else "platforms"),
                    fg="cyan",
                    nl=False)
        click.secho(" command.", fg="yellow")
    else:
        click.secho("Please wait while updating %s ..." % what, fg="yellow")
        if what == "platforms":
            ctx.invoke(cmd_platforms_update)
        elif what == "libraries":
            ctx.invoke(cmd_libraries_update)
        click.echo()

        telemetry.on_event(category="Auto",
                           action="Update",
                           label=what.title())

    click.echo("*" * terminal_width)
    click.echo("")
Exemplo n.º 18
0
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()

    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" if what == "libraries" else "platforms"),
                    fg="cyan", nl=False)
        click.secho(" command.", fg="yellow")
    else:
        click.secho("Please wait while updating %s ..." % what, fg="yellow")
        if what == "platforms":
            ctx.invoke(cmd_platforms_update)
        elif what == "libraries":
            ctx.invoke(cmd_libraries_update)
        click.echo()

        telemetry.on_event(category="Auto", action="Update",
                           label=what.title())

    click.echo("*" * terminal_width)
    click.echo("")
Exemplo n.º 19
0
def cli(environment, target, upload_port):

    config = get_project_config()

    if not config.sections():
        raise ProjectEnvsNotAvaialable()

    unknown = set(environment) - set([s[4:] for s in config.sections()])
    if unknown:
        raise UnknownEnvNames(", ".join(unknown))

    for section in config.sections():
        # skip main configuration section
        if section == "platformio":
            continue
        elif section[:4] != "env:":
            raise InvalidEnvName(section)

        envname = section[4:]
        if environment and envname not in environment:
            # echo("Skipped %s environment" % style(envname, fg="yellow"))
            continue

        echo("Processing %s environment:" % style(envname, fg="cyan"))

        variables = ["PIOENV=" + envname]
        if upload_port:
            variables.append("UPLOAD_PORT=%s" % upload_port)
        for k, v in config.items(section):
            k = k.upper()
            if k == "TARGETS" or (k == "UPLOAD_PORT" and upload_port):
                continue
            variables.append("%s=%s" % (k.upper(), v))

        envtargets = []
        if target:
            envtargets = [t for t in target]
        elif config.has_option(section, "targets"):
            envtargets = config.get(section, "targets").split()

        if not config.has_option(section, "platform"):
            raise UndefinedEnvPlatform(envname)

        p = PlatformFactory().newPlatform(config.get(section, "platform"))
        result = p.run(variables, envtargets)
        secho(result['out'], fg="green")
        secho(result['err'],
              fg="red" if "Error" in result['err'] else "yellow")
Exemplo n.º 20
0
def update_platform_docs():
    for name in PlatformFactory.get_platforms().keys():
        rst_path = join(
            dirname(realpath(__file__)), "..", "docs", "platforms",
            "%s.rst" % name)
        with open(rst_path, "w") as f:
            f.write(generate_platform(name))
Exemplo n.º 21
0
def platforms_uninstall(platforms):

    for platform in platforms:
        p = PlatformFactory.newPlatform(platform)
        if p.uninstall():
            click.secho("The platform '%s' has been successfully "
                        "uninstalled!" % platform, fg="green")
Exemplo n.º 22
0
def platforms_uninstall(platforms):

    for platform in platforms:
        p = PlatformFactory.newPlatform(platform)
        if p.uninstall():
            click.secho("The platform '%s' has been successfully "
                        "uninstalled!" % platform, fg="green")
Exemplo n.º 23
0
 def _upgrade_to_1_0_0(self, ctx):  # pylint: disable=R0201
     installed_platforms = PlatformFactory.get_platforms(
         installed=True).keys()
     if installed_platforms:
         ctx.invoke(cmd_install, platforms=installed_platforms)
     ctx.invoke(cli_update)
     return True
Exemplo n.º 24
0
def _autoinstall_platform(ctx, platform):
    installed_platforms = PlatformFactory.get_platforms(installed=True).keys()
    if (platform not in installed_platforms and
        (not app.get_setting("enable_prompts")
         or click.confirm("The platform '%s' has not been installed yet. "
                          "Would you like to install it now?" % platform))):
        ctx.invoke(cmd_platforms_install, platforms=[platform])
Exemplo n.º 25
0
def _install_dependent_platforms(ctx, platforms):
    installed_platforms = PlatformFactory.get_platforms(installed=True).keys()
    if set(platforms) <= set(installed_platforms):
        return
    ctx.invoke(
        cli_platforms_install,
        platforms=list(set(platforms) - set(installed_platforms))
    )
Exemplo n.º 26
0
def platforms_list(json_output):

    installed_platforms = PlatformFactory.get_platforms(installed=True).keys()
    installed_platforms.sort()

    data = []
    for platform in installed_platforms:
        p = PlatformFactory.newPlatform(platform)
        data.append({"name": platform, "packages": p.get_installed_packages()})

    if json_output:
        click.echo(json.dumps(data))
    else:
        for item in data:
            click.echo("{name:<20} with packages: {pkgs}".format(
                name=click.style(item['name'], fg="cyan"),
                pkgs=", ".join(item['packages'])))
Exemplo n.º 27
0
def _install_dependent_platforms(ctx, platforms):
    installed_platforms = PlatformFactory.get_platforms(installed=True).keys()
    if set(platforms) <= set(installed_platforms):
        return
    ctx.invoke(
        cli_platforms_install,
        platforms=list(set(platforms) - set(installed_platforms))
    )
Exemplo n.º 28
0
def platforms_install(platforms, with_package, without_package,
                      skip_default_package):
    for platform in platforms:
        p = PlatformFactory.newPlatform(platform)
        if p.install(with_package, without_package, skip_default_package):
            click.secho("The platform '%s' has been successfully installed!\n"
                        "The rest of packages will be installed automatically "
                        "depending on your build environment." % platform,
                        fg="green")
Exemplo n.º 29
0
def update_platform_docs():
    for name in PlatformFactory.get_platforms().keys():
        platforms_dir = join(dirname(realpath(__file__)),
                             "..", "docs", "platforms")
        rst_path = join(platforms_dir, "%s.rst" % name)
        with open(rst_path, "w") as f:
            f.write(generate_platform(name))
            if isfile(join(platforms_dir, "%s_extra.rst" % name)):
                f.write("\n.. include:: %s_extra.rst\n" % name)
Exemplo n.º 30
0
def update_platform_docs():
    for name in PlatformFactory.get_platforms().keys():
        platforms_dir = join(dirname(realpath(__file__)), "..", "docs",
                             "platforms")
        rst_path = join(platforms_dir, "%s.rst" % name)
        with open(rst_path, "w") as f:
            f.write(generate_platform(name))
            if isfile(join(platforms_dir, "%s_extra.rst" % name)):
                f.write("\n.. include:: %s_extra.rst\n" % name)
Exemplo n.º 31
0
def cli(platform):
    p = PlatformFactory().newPlatform(platform)
    if platform not in PackageManager.get_installed():
        raise PlatformNotInstalledYet(platform)

    # print info about platform
    echo("{name:<20} - {info}".format(name=style(p.get_name(), fg="cyan"),
                                      info=p.get_short_info()))

    pm = PackageManager(platform)
    for name, data in pm.get_installed(platform).items():
        pkgalias = p.get_pkg_alias(name)
        echo("----------")
        echo("Package: %s" % style(name, fg="yellow"))
        if pkgalias:
            echo("Alias: %s" % pkgalias)
        echo("Location: %s" % join(pm.get_platform_dir(), data['path']))
        echo("Version: %d" % int(data['version']))
Exemplo n.º 32
0
def platforms_install(platforms, with_package, without_package,
                      skip_default_package):
    for platform in platforms:
        p = PlatformFactory.newPlatform(platform)
        if p.install(with_package, without_package, skip_default_package):
            click.secho(
                "The platform '%s' has been successfully installed!\n"
                "The rest of packages will be installed automatically "
                "depending on your build environment." % platform,
                fg="green")
Exemplo n.º 33
0
def platforms_list(json_output):

    installed_platforms = PlatformFactory.get_platforms(installed=True).keys()
    installed_platforms.sort()

    data = []
    for platform in installed_platforms:
        p = PlatformFactory.newPlatform(platform)
        data.append({"name": platform, "packages": p.get_installed_packages()})

    if json_output:
        click.echo(json.dumps(data))
    else:
        for item in data:
            click.echo(
                "{name:<20} with packages: {pkgs}".format(
                    name=click.style(item["name"], fg="cyan"), pkgs=", ".join(item["packages"])
                )
            )
Exemplo n.º 34
0
    def _get_platformio_packages(self):
        log.debug("Getting Scons Packages")
        ori_current_dir = os.getcwd()
        ori_click_confirm = click.confirm

        def click_confirm(message):
            print message
            return True

        click.confirm = click_confirm
        try:
            os.chdir(pm.PLATFORMIO_WORKSPACE_SKELETON)
            config = util.get_project_config()
            for section in config.sections():
                env_options_dict = {x[0]: x[1] for x in config.items(section)}
                platform = PlatformFactory.newPlatform(env_options_dict["platform"])
                log.info("getting packages for: {}".format(env_options_dict))
                platform.configure_default_packages(env_options_dict, ["upload"])
                platform._install_default_packages()
            os.chdir(ori_current_dir)

            log.info("all platformio packages are successfully installed")

            platformio_packages_path = os.path.abspath(util.get_home_dir())

            def is_doc(file_path):
                is_doc_condition = os.sep + "doc" + os.sep not in file_path
                is_doc_condition = is_doc_condition and os.sep + "examples" + os.sep not in file_path
                is_doc_condition = is_doc_condition and os.sep + "tool-scons" + os.sep not in file_path
                is_doc_condition = is_doc_condition and os.sep + "README" not in file_path.upper()
                return not is_doc_condition

            # installerPlatformioPackagesPath = self._getPlatformIOPackagesPath()
            # if os.path.exists(installerPlatformioPackagesPath):
            #     shutil.rmtree(installerPlatformioPackagesPath)
            #
            # os.makedirs(installerPlatformioPackagesPath)

            log.info("Cleaning platformio packages files")
            all_files = sorted(utils.find_files(platformio_packages_path, ["*", "**" + os.sep + "*"]), reverse=True)
            for i, f in enumerate(all_files):
                if is_doc(f):
                    if os.path.isfile(f):
                        os.remove(f)
                    else:
                        try:
                            os.rmdir(f)
                        except:
                            shutil.rmtree(f)
        finally:
            os.chdir(ori_current_dir)
            click.confirm = ori_click_confirm
Exemplo n.º 35
0
    def _run(self):
        if "platform" not in self.options:
            raise exception.UndefinedEnvPlatform(self.name)

        platform = self.options['platform']
        build_vars = self._get_build_variables()
        build_targets = self._get_build_targets()

        telemetry.on_run_environment(self.options, build_targets)

        # install dependent libraries
        if "lib_install" in self.options:
            _autoinstall_libs(self.cmd_ctx, self.options['lib_install'])

        p = PlatformFactory.newPlatform(platform)
        return p.run(build_vars, build_targets, self.verbose_level)
Exemplo n.º 36
0
    def _run(self):
        if "platform" not in self.options:
            raise exception.UndefinedEnvPlatform(self.name)

        platform = self.options['platform']
        build_vars = self._get_build_variables()
        build_targets = self._get_build_targets()

        telemetry.on_run_environment(self.options, build_targets)

        # install dependent libraries
        if "lib_install" in self.options:
            _autoinstall_libs(self.cmd_ctx, self.options['lib_install'])

        p = PlatformFactory.newPlatform(platform)
        return p.run(build_vars, build_targets, self.verbose_level)
Exemplo n.º 37
0
    def _upgrade_to_0_9_0(self, ctx):  # pylint: disable=R0201
        prev_platforms = []

        # remove platform's folder (obsoleted package structure)
        for name in PlatformFactory.get_platforms().keys():
            pdir = join(get_home_dir(), name)
            if not isdir(pdir):
                continue
            prev_platforms.append(name)
            rmtree(pdir)

        # remove unused files
        for fname in (".pioupgrade", "installed.json"):
            if isfile(join(get_home_dir(), fname)):
                remove(join(get_home_dir(), fname))

        if prev_platforms:
            ctx.invoke(cmd_install, platforms=prev_platforms)

        return True
Exemplo n.º 38
0
def generate_platform(name):
    print "Processing platform: %s" % name
    lines = []

    lines.append("""..  Copyright 2014-2015 Ivan Kravets <*****@*****.**>
    Licensed under the Apache License, Version 2.0 (the "License");
    you may not use this file except in compliance with the License.
    You may obtain a copy of the License at
       http://www.apache.org/licenses/LICENSE-2.0
    Unless required by applicable law or agreed to in writing, software
    distributed under the License is distributed on an "AS IS" BASIS,
    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    See the License for the specific language governing permissions and
    limitations under the License.
""")

    lines.append(".. _platform_%s:" % name)
    lines.append("")

    _title = "Platform ``%s``" % name
    lines.append(_title)
    lines.append("=" * len(_title))

    p = PlatformFactory.newPlatform(name)
    lines.append(p.get_description())
    lines.append("""
For more detailed information please visit `vendor site <%s>`_.""" %
                 p.get_vendor_url())
    lines.append("""
.. contents::""")

    #
    # Packages
    #
    _packages_content = generate_packages(p.get_packages(), p.is_embedded())
    if _packages_content:
        lines.append(_packages_content)

    #
    # Frameworks
    #
    _frameworks = util.get_frameworks()
    _frameworks_lines = []
    for framework in sorted(_frameworks.keys()):
        if not is_compat_platform_and_framework(name, framework):
            continue
        _frameworks_lines.append("""
    * - :ref:`framework_{type_}`
      - {description}""".format(
            type_=framework,
            description=_frameworks[framework]['description']))

    if _frameworks_lines:
        lines.append("""
Frameworks
----------
.. list-table::
    :header-rows:  1

    * - Name
      - Description""")
        lines.extend(_frameworks_lines)

    #
    # Boards
    #
    vendors = {}
    for board, data in util.get_boards().items():
        platform = data['platform']
        vendor = data['vendor']
        if name in platform:
            if vendor in vendors:
                vendors[vendor].append({board: data})
            else:
                vendors[vendor] = [{board: data}]

    if vendors:
        lines.append("""
Boards
------

.. note::
    * You can list pre-configured boards by :ref:`cmd_boards` command or
      `PlatformIO Boards Explorer <http://platformio.org/#!/boards>`_
    * For more detailed ``board`` information please scroll tables below by
      horizontal.
""")

    for vendor, boards in sorted(vendors.iteritems()):
        lines.append(str(vendor))
        lines.append("~" * len(vendor))
        lines.append(generate_boards(boards))

    return "\n".join(lines)
Exemplo n.º 39
0
def generate_framework(type_, data):
    print "Processing framework: %s" % type_
    lines = []

    lines.append("""..  Copyright 2014-2015 Ivan Kravets <*****@*****.**>
    Licensed under the Apache License, Version 2.0 (the "License");
    you may not use this file except in compliance with the License.
    You may obtain a copy of the License at
       http://www.apache.org/licenses/LICENSE-2.0
    Unless required by applicable law or agreed to in writing, software
    distributed under the License is distributed on an "AS IS" BASIS,
    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    See the License for the specific language governing permissions and
    limitations under the License.
""")

    lines.append(".. _framework_%s:" % type_)
    lines.append("")

    _title = "Framework ``%s``" % type_
    lines.append(_title)
    lines.append("=" * len(_title))
    lines.append(data['description'])
    lines.append("""
For more detailed information please visit `vendor site <%s>`_.
""" % data['url'])

    lines.append(".. contents::")

    lines.append("""
Platforms
---------
.. list-table::
    :header-rows:  1

    * - Name
      - Description""")

    _found_platform = False
    for platform in sorted(PlatformFactory.get_platforms().keys()):
        if not is_compat_platform_and_framework(platform, type_):
            continue
        _found_platform = True
        p = PlatformFactory.newPlatform(platform)
        lines.append("""
    * - :ref:`platform_{type_}`
      - {description}""".format(
            type_=platform,
            description=p.get_description()))
    if not _found_platform:
        del lines[-1]

    lines.append("""
Boards
------

.. note::
    * You can list pre-configured boards by :ref:`cmd_boards` command or
      `PlatformIO Boards Explorer <http://platformio.org/#!/boards>`_
    * For more detailed ``board`` information please scroll tables below by horizontal.
""")

    vendors = {}
    for board, data in util.get_boards().items():
        frameworks = data['frameworks']
        vendor = data['vendor']
        if type_ in frameworks:
            if vendor in vendors:
                vendors[vendor].append({board: data})
            else:
                vendors[vendor] = [{board: data}]
    for vendor, boards in sorted(vendors.iteritems()):
        lines.append(str(vendor))
        lines.append("~" * len(vendor))
        lines.append(generate_boards(boards))
    return "\n".join(lines)
Exemplo n.º 40
0
def generate_platform(name):
    print "Processing platform: %s" % name
    lines = []

    lines.append("""..  Copyright 2014-2015 Ivan Kravets <*****@*****.**>
    Licensed under the Apache License, Version 2.0 (the "License");
    you may not use this file except in compliance with the License.
    You may obtain a copy of the License at
       http://www.apache.org/licenses/LICENSE-2.0
    Unless required by applicable law or agreed to in writing, software
    distributed under the License is distributed on an "AS IS" BASIS,
    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    See the License for the specific language governing permissions and
    limitations under the License.
""")

    lines.append(".. _platform_%s:" % name)
    lines.append("")

    _title = "Platform ``%s``" % name
    lines.append(_title)
    lines.append("=" * len(_title))

    p = PlatformFactory.newPlatform(name)
    lines.append(p.get_description())
    lines.append("""
For more detailed information please visit `vendor site <%s>`_.""" %
                 p.get_vendor_url())
    lines.append("""
.. contents::""")

    #
    # Packages
    #
    _packages_content = generate_packages(p.get_packages(), p.is_embedded())
    if _packages_content:
        lines.append(_packages_content)

    #
    # Frameworks
    #
    _frameworks = util.get_frameworks()
    _frameworks_lines = []
    for framework in sorted(_frameworks.keys()):
        if not is_compat_platform_and_framework(name, framework):
            continue
        _frameworks_lines.append("""
    * - :ref:`framework_{type_}`
      - {description}""".format(
            type_=framework,
            description=_frameworks[framework]['description']))

    if _frameworks_lines:
        lines.append("""
Frameworks
----------
.. list-table::
    :header-rows:  1

    * - Name
      - Description""")
        lines.extend(_frameworks_lines)

    #
    # Boards
    #
    vendors = {}
    for board, data in util.get_boards().items():
        platform = data['platform']
        vendor = data['vendor']
        if name in platform:
            if vendor in vendors:
                vendors[vendor].append({board: data})
            else:
                vendors[vendor] = [{board: data}]

    if vendors:
        lines.append("""
Boards
------

.. note::
    * You can list pre-configured boards by :ref:`cmd_boards` command or
      `PlatformIO Boards Explorer <http://platformio.org/#!/boards>`_
    * For more detailed ``board`` information please scroll tables below by
      horizontal.
""")

    for vendor, boards in sorted(vendors.iteritems()):
        lines.append(str(vendor))
        lines.append("~" * len(vendor))
        lines.append(generate_boards(boards))

    return "\n".join(lines)
Exemplo n.º 41
0
def generate_framework(type_, data):
    print "Processing framework: %s" % type_
    lines = []

    lines.append("""..  Copyright 2014-2015 Ivan Kravets <*****@*****.**>
    Licensed under the Apache License, Version 2.0 (the "License");
    you may not use this file except in compliance with the License.
    You may obtain a copy of the License at
       http://www.apache.org/licenses/LICENSE-2.0
    Unless required by applicable law or agreed to in writing, software
    distributed under the License is distributed on an "AS IS" BASIS,
    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    See the License for the specific language governing permissions and
    limitations under the License.
""")

    lines.append(".. _framework_%s:" % type_)
    lines.append("")

    _title = "Framework ``%s``" % type_
    lines.append(_title)
    lines.append("=" * len(_title))
    lines.append(data['description'])
    lines.append("""
For more detailed information please visit `vendor site <%s>`_.
""" % data['url'])

    lines.append(".. contents::")

    lines.append("""
Platforms
---------
.. list-table::
    :header-rows:  1

    * - Name
      - Description""")

    _found_platform = False
    for platform in sorted(PlatformFactory.get_platforms().keys()):
        if not is_compat_platform_and_framework(platform, type_):
            continue
        _found_platform = True
        p = PlatformFactory.newPlatform(platform)
        lines.append("""
    * - :ref:`platform_{type_}`
      - {description}""".format(type_=platform,
                                description=p.get_description()))
    if not _found_platform:
        del lines[-1]

    lines.append("""
Boards
------

.. note::
    * You can list pre-configured boards by :ref:`cmd_boards` command or
      `PlatformIO Boards Explorer <http://platformio.org/#!/boards>`_
    * For more detailed ``board`` information please scroll tables below by horizontal.
""")

    vendors = {}
    for board, data in util.get_boards().items():
        frameworks = data['frameworks']
        vendor = data['vendor']
        if type_ in frameworks:
            if vendor in vendors:
                vendors[vendor].append({board: data})
            else:
                vendors[vendor] = [{board: data}]
    for vendor, boards in sorted(vendors.iteritems()):
        lines.append(str(vendor))
        lines.append("~" * len(vendor))
        lines.append(generate_boards(boards))
    return "\n".join(lines)
Exemplo n.º 42
0
def is_compat_platform_and_framework(platform, framework):
    p = PlatformFactory.newPlatform(platform)
    for pkg in p.get_packages().keys():
        if pkg.startswith("framework-%s" % framework):
            return True
    return False
Exemplo n.º 43
0
def generate_platform(name):
    print "Processing platform: %s" % name
    lines = []

    lines.append(".. _platform_%s:" % name)
    lines.append("")

    _title = "Platform ``%s``" % name
    lines.append(_title)
    lines.append("=" * len(_title))

    p = PlatformFactory.newPlatform(name)
    lines.append(p.get_description())
    lines.append("""
For more detailed information please visit `vendor site <%s>`_.""" %
                 p.get_vendor_url())
    lines.append("""
.. contents::""")
    lines.append("""
Packages
--------
""")
    lines.append(generate_packages(p.get_packages()))

    lines.append("""
Frameworks
----------
.. list-table::
    :header-rows:  1

    * - Name
      - Description""")

    _frameworks = util.get_frameworks()
    for framework in sorted(_frameworks.keys()):
        if not is_compat_platform_and_framework(name, framework):
            continue
        lines.append("""
    * - :ref:`framework_{type_}`
      - {description}""".format(
            type_=framework,
            description=_frameworks[framework]['description']))

    lines.append("""
Boards
------

.. note::
    * You can list pre-configured boards by :ref:`cmd_boards` command or
      `PlatformIO Boards Explorer <http://platformio.org/#!/boards>`_
    * For more detailed ``board`` information please scroll tables below by
      horizontal.
""")

    vendors = {}
    for board, data in util.get_boards().items():
        platform = data['platform']
        vendor = data['vendor']
        if name in platform:
            if vendor in vendors:
                vendors[vendor].append({board: data})
            else:
                vendors[vendor] = [{board: data}]
    for vendor, boards in sorted(vendors.iteritems()):
        lines.append(str(vendor))
        lines.append("~" * len(vendor))
        lines.append(generate_boards(boards))
    return "\n".join(lines)