本文整理汇总了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")