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


Python PlatformFactory.run方法代码示例

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


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

示例1: cli

# 需要导入模块: from platformio.platforms.base import PlatformFactory [as 别名]
# 或者: from platformio.platforms.base.PlatformFactory import run [as 别名]
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,代码行数:50,代码来源:run.py


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