本文整理汇总了Python中platformio.platforms.base.PlatformFactory.newPlatform方法的典型用法代码示例。如果您正苦于以下问题:Python PlatformFactory.newPlatform方法的具体用法?Python PlatformFactory.newPlatform怎么用?Python PlatformFactory.newPlatform使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类platformio.platforms.base.PlatformFactory
的用法示例。
在下文中一共展示了PlatformFactory.newPlatform方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: generate_framework
# 需要导入模块: from platformio.platforms.base import PlatformFactory [as 别名]
# 或者: from platformio.platforms.base.PlatformFactory import newPlatform [as 别名]
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)
示例2: cli
# 需要导入模块: from platformio.platforms.base import PlatformFactory [as 别名]
# 或者: from platformio.platforms.base.PlatformFactory import newPlatform [as 别名]
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):
click.secho("The platform '%s' has been successfully installed!" %
platform, fg="green")
示例3: _autoinstall_platform
# 需要导入模块: from platformio.platforms.base import PlatformFactory [as 别名]
# 或者: from platformio.platforms.base.PlatformFactory import newPlatform [as 别名]
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)
示例4: platforms_search
# 需要导入模块: from platformio.platforms.base import PlatformFactory [as 别名]
# 或者: from platformio.platforms.base.PlatformFactory import newPlatform [as 别名]
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()
示例5: platforms_show
# 需要导入模块: from platformio.platforms.base import PlatformFactory [as 别名]
# 或者: from platformio.platforms.base.PlatformFactory import newPlatform [as 别名]
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"))
示例6: platforms_uninstall
# 需要导入模块: from platformio.platforms.base import PlatformFactory [as 别名]
# 或者: from platformio.platforms.base.PlatformFactory import newPlatform [as 别名]
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")
示例7: _run_environment
# 需要导入模块: from platformio.platforms.base import PlatformFactory [as 别名]
# 或者: from platformio.platforms.base.PlatformFactory import newPlatform [as 别名]
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)
示例8: cli
# 需要导入模块: from platformio.platforms.base import PlatformFactory [as 别名]
# 或者: from platformio.platforms.base.PlatformFactory import newPlatform [as 别名]
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()
示例9: platforms_install
# 需要导入模块: from platformio.platforms.base import PlatformFactory [as 别名]
# 或者: from platformio.platforms.base.PlatformFactory import newPlatform [as 别名]
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")
示例10: check_internal_updates
# 需要导入模块: from platformio.platforms.base import PlatformFactory [as 别名]
# 或者: from platformio.platforms.base.PlatformFactory import newPlatform [as 别名]
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("")
示例11: _run
# 需要导入模块: from platformio.platforms.base import PlatformFactory [as 别名]
# 或者: from platformio.platforms.base.PlatformFactory import newPlatform [as 别名]
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)
示例12: platforms_list
# 需要导入模块: from platformio.platforms.base import PlatformFactory [as 别名]
# 或者: from platformio.platforms.base.PlatformFactory import newPlatform [as 别名]
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"])
)
)
示例13: generate_platform
# 需要导入模块: from platformio.platforms.base import PlatformFactory [as 别名]
# 或者: from platformio.platforms.base.PlatformFactory import newPlatform [as 别名]
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)
示例14: is_compat_platform_and_framework
# 需要导入模块: from platformio.platforms.base import PlatformFactory [as 别名]
# 或者: from platformio.platforms.base.PlatformFactory import newPlatform [as 别名]
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
示例15: generate_framework
# 需要导入模块: from platformio.platforms.base import PlatformFactory [as 别名]
# 或者: from platformio.platforms.base.PlatformFactory import newPlatform [as 别名]
def generate_framework(type_, data):
print "Processing framework: %s" % type_
lines = []
lines.append(""".. Copyright 2014-2015 Ivan Kravets <[email protected]>
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)