本文整理汇总了Python中platformio.platforms.base.PlatformFactory.get_platforms方法的典型用法代码示例。如果您正苦于以下问题:Python PlatformFactory.get_platforms方法的具体用法?Python PlatformFactory.get_platforms怎么用?Python PlatformFactory.get_platforms使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类platformio.platforms.base.PlatformFactory
的用法示例。
在下文中一共展示了PlatformFactory.get_platforms方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _upgrade_to_1_0_0
# 需要导入模块: from platformio.platforms.base import PlatformFactory [as 别名]
# 或者: from platformio.platforms.base.PlatformFactory import get_platforms [as 别名]
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
示例2: generate_framework
# 需要导入模块: from platformio.platforms.base import PlatformFactory [as 别名]
# 或者: from platformio.platforms.base.PlatformFactory import get_platforms [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)
示例3: _autoinstall_platform
# 需要导入模块: from platformio.platforms.base import PlatformFactory [as 别名]
# 或者: from platformio.platforms.base.PlatformFactory import get_platforms [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 get_platforms [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: update_platform_docs
# 需要导入模块: from platformio.platforms.base import PlatformFactory [as 别名]
# 或者: from platformio.platforms.base.PlatformFactory import get_platforms [as 别名]
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))
示例6: platforms_show
# 需要导入模块: from platformio.platforms.base import PlatformFactory [as 别名]
# 或者: from platformio.platforms.base.PlatformFactory import get_platforms [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"))
示例7: _run_environment
# 需要导入模块: from platformio.platforms.base import PlatformFactory [as 别名]
# 或者: from platformio.platforms.base.PlatformFactory import get_platforms [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: _install_dependent_platforms
# 需要导入模块: from platformio.platforms.base import PlatformFactory [as 别名]
# 或者: from platformio.platforms.base.PlatformFactory import get_platforms [as 别名]
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))
)
示例9: update_platform_docs
# 需要导入模块: from platformio.platforms.base import PlatformFactory [as 别名]
# 或者: from platformio.platforms.base.PlatformFactory import get_platforms [as 别名]
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)
示例10: cli
# 需要导入模块: from platformio.platforms.base import PlatformFactory [as 别名]
# 或者: from platformio.platforms.base.PlatformFactory import get_platforms [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()
示例11: check_internal_updates
# 需要导入模块: from platformio.platforms.base import PlatformFactory [as 别名]
# 或者: from platformio.platforms.base.PlatformFactory import get_platforms [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("")
示例12: platforms_list
# 需要导入模块: from platformio.platforms.base import PlatformFactory [as 别名]
# 或者: from platformio.platforms.base.PlatformFactory import get_platforms [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: _upgrade_to_0_9_0
# 需要导入模块: from platformio.platforms.base import PlatformFactory [as 别名]
# 或者: from platformio.platforms.base.PlatformFactory import get_platforms [as 别名]
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
示例14: generate_framework
# 需要导入模块: from platformio.platforms.base import PlatformFactory [as 别名]
# 或者: from platformio.platforms.base.PlatformFactory import get_platforms [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)