当前位置: 首页>>代码示例>>Python>>正文


Python base.PlatformFactory类代码示例

本文整理汇总了Python中platformio.platforms.base.PlatformFactory的典型用法代码示例。如果您正苦于以下问题:Python PlatformFactory类的具体用法?Python PlatformFactory怎么用?Python PlatformFactory使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了PlatformFactory类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: platforms_show

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"))
开发者ID:akaash-nigam,项目名称:platformio,代码行数:29,代码来源:platforms.py

示例2: cli

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")
开发者ID:bettabacon,项目名称:platformio,代码行数:7,代码来源:install.py

示例3: platforms_search

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()
开发者ID:akaash-nigam,项目名称:platformio,代码行数:34,代码来源:platforms.py

示例4: generate_framework

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)
开发者ID:Lutino,项目名称:platformio,代码行数:60,代码来源:docspregen.py

示例5: _autoinstall_platform

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)
开发者ID:jrobeson,项目名称:platformio,代码行数:26,代码来源:run.py

示例6: _run_environment

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)
开发者ID:Lutino,项目名称:platformio,代码行数:32,代码来源:run.py

示例7: cli

def cli():

    for platform in PackageManager.get_installed().keys():
        echo("\nPlatform %s" % style(platform, fg="cyan"))
        echo("--------")
        p = PlatformFactory().newPlatform(platform)
        p.update()
开发者ID:bettabacon,项目名称:platformio,代码行数:7,代码来源:update.py

示例8: cli

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()
开发者ID:muchirijohn,项目名称:platformio,代码行数:10,代码来源:update.py

示例9: cli

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")
开发者ID:bettabacon,项目名称:platformio,代码行数:11,代码来源:uninstall.py

示例10: cli

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")
开发者ID:bettabacon,项目名称:platformio,代码行数:48,代码来源:run.py

示例11: check_internal_updates

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("")
开发者ID:akaash-nigam,项目名称:platformio,代码行数:48,代码来源:maintenance.py

示例12: _upgrade_to_1_0_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
开发者ID:muchirijohn,项目名称:platformio,代码行数:7,代码来源:maintenance.py

示例13: update_platform_docs

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))
开发者ID:Lutino,项目名称:platformio,代码行数:7,代码来源:docspregen.py

示例14: platforms_uninstall

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")
开发者ID:akaash-nigam,项目名称:platformio,代码行数:7,代码来源:platforms.py

示例15: _install_dependent_platforms

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))
    )
开发者ID:Cgruppo,项目名称:platformio,代码行数:8,代码来源:init.py


注:本文中的platformio.platforms.base.PlatformFactory类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。