コード例 #1
0
def system_prune(force, dry_run, cache, core_packages, platform_packages):
    if dry_run:
        click.secho(
            "Dry run mode (do not prune, only show data that will be removed)",
            fg="yellow",
        )
        click.echo()

    reclaimed_cache = 0
    reclaimed_core_packages = 0
    reclaimed_platform_packages = 0
    prune_all = not any([cache, core_packages, platform_packages])

    if cache or prune_all:
        reclaimed_cache = prune_cached_data(force, dry_run)
        click.echo()

    if core_packages or prune_all:
        reclaimed_core_packages = prune_core_packages(force, dry_run)
        click.echo()

    if platform_packages or prune_all:
        reclaimed_platform_packages = prune_platform_packages(force, dry_run)
        click.echo()

    click.secho(
        "Total reclaimed space: %s"
        % fs.humanize_file_size(
            reclaimed_cache + reclaimed_core_packages + reclaimed_platform_packages
        ),
        fg="green",
    )
コード例 #2
0
 def _get_hardware_data():
     data = ["HARDWARE:"]
     mcu = env.subst("$BOARD_MCU")
     f_cpu = env.subst("$BOARD_F_CPU")
     if mcu:
         data.append(mcu.upper())
     if f_cpu:
         f_cpu = int("".join([c for c in str(f_cpu) if c.isdigit()]))
         data.append("%dMHz," % (f_cpu / 1000000))
     if not board_config:
         return data
     ram = board_config.get("upload", {}).get("maximum_ram_size")
     flash = board_config.get("upload", {}).get("maximum_size")
     data.append("%s RAM, %s Flash" %
                 (fs.humanize_file_size(ram), fs.humanize_file_size(flash)))
     return data
コード例 #3
0
ファイル: boards.py プロジェクト: Globalync/platformio-core
def print_boards(boards):
    click.echo(
        tabulate(
            [
                (
                    click.style(b["id"], fg="cyan"),
                    b["mcu"],
                    "%dMHz" % (b["fcpu"] / 1000000),
                    fs.humanize_file_size(b["rom"]),
                    fs.humanize_file_size(b["ram"]),
                    b["name"],
                )
                for b in boards
            ],
            headers=["ID", "MCU", "Frequency", "Flash", "RAM", "Name"],
        )
    )
コード例 #4
0
ファイル: command.py プロジェクト: Globalync/platformio-core
def system_prune(force):
    click.secho("WARNING! This will remove:", fg="yellow")
    click.echo(" - cached API requests")
    click.echo(" - cached package downloads")
    click.echo(" - temporary data")
    if not force:
        click.confirm("Do you want to continue?", abort=True)

    reclaimed_total = 0
    cache_dir = get_project_cache_dir()
    if os.path.isdir(cache_dir):
        reclaimed_total += fs.calculate_folder_size(cache_dir)
        fs.rmtree(cache_dir)

    click.secho("Total reclaimed space: %s" %
                fs.humanize_file_size(reclaimed_total),
                fg="green")
コード例 #5
0
ファイル: prune.py プロジェクト: smarpug/platformio-core
def prune_cached_data(force=False, dry_run=False, silent=False):
    reclaimed_space = 0
    if not silent:
        click.secho("Prune cached data:", bold=True)
        click.echo(" - cached API requests")
        click.echo(" - cached package downloads")
        click.echo(" - temporary data")
    cache_dir = get_project_cache_dir()
    if os.path.isdir(cache_dir):
        reclaimed_space += fs.calculate_folder_size(cache_dir)
        if not dry_run:
            if not force:
                click.confirm("Do you want to continue?", abort=True)
            fs.rmtree(cache_dir)
    if not silent:
        click.secho("Space on disk: %s" %
                    fs.humanize_file_size(reclaimed_space))
    return reclaimed_space
コード例 #6
0
def update_embedded_board(rst_path, board):
    platform = PlatformFactory.new(board["platform"])
    board_config = platform.board_config(board["id"])

    board_manifest_url = platform.repository_url
    assert board_manifest_url
    if board_manifest_url.endswith(".git"):
        board_manifest_url = board_manifest_url[:-4]
    board_manifest_url += "/blob/master/boards/%s.json" % board["id"]

    variables = dict(
        id=board["id"],
        name=board["name"],
        platform=board["platform"],
        platform_description=platform.description,
        url=campaign_url(board["url"]),
        mcu=board_config.get("build", {}).get("mcu", ""),
        mcu_upper=board["mcu"].upper(),
        f_cpu=board["fcpu"],
        f_cpu_mhz=int(int(board["fcpu"]) / 1000000),
        ram=fs.humanize_file_size(board["ram"]),
        rom=fs.humanize_file_size(board["rom"]),
        vendor=board["vendor"],
        board_manifest_url=board_manifest_url,
        upload_protocol=board_config.get("upload.protocol", ""),
    )

    lines = [RST_COPYRIGHT]
    lines.append(".. _board_{platform}_{id}:".format(**variables))
    lines.append("")
    lines.append(board["name"])
    lines.append("=" * len(board["name"]))
    lines.append("""
.. contents::

Hardware
--------

Platform :ref:`platform_{platform}`: {platform_description}

.. list-table::

  * - **Microcontroller**
    - {mcu_upper}
  * - **Frequency**
    - {f_cpu_mhz:d}MHz
  * - **Flash**
    - {rom}
  * - **RAM**
    - {ram}
  * - **Vendor**
    - `{vendor} <{url}>`__
""".format(**variables))

    #
    # Configuration
    #
    lines.append("""
Configuration
-------------

Please use ``{id}`` ID for :ref:`projectconf_env_board` option in :ref:`projectconf`:

.. code-block:: ini

  [env:{id}]
  platform = {platform}
  board = {id}

You can override default {name} settings per build environment using
``board_***`` option, where ``***`` is a JSON object path from
board manifest `{id}.json <{board_manifest_url}>`_. For example,
``board_build.mcu``, ``board_build.f_cpu``, etc.

.. code-block:: ini

  [env:{id}]
  platform = {platform}
  board = {id}

  ; change microcontroller
  board_build.mcu = {mcu}

  ; change MCU frequency
  board_build.f_cpu = {f_cpu}L
""".format(**variables))

    #
    # Uploading
    #
    upload_protocols = board_config.get("upload.protocols", [])
    if len(upload_protocols) > 1:
        lines.append("""
Uploading
---------
%s supports the next uploading protocols:
""" % board["name"])
        for protocol in sorted(upload_protocols):
            lines.append("* ``%s``" % protocol)
        lines.append("""
Default protocol is ``%s``""" % variables["upload_protocol"])
        lines.append("""
You can change upload protocol using :ref:`projectconf_upload_protocol` option:

.. code-block:: ini

  [env:{id}]
  platform = {platform}
  board = {id}

  upload_protocol = {upload_protocol}
""".format(**variables))

    #
    # Debugging
    #
    lines.append("Debugging")
    lines.append("---------")
    if not board.get("debug"):
        lines.append(
            ":ref:`piodebug` currently does not support {name} board.".format(
                **variables))
    else:
        default_debug_tool = board_config.get_debug_tool_name()
        has_onboard_debug = any(
            t.get("onboard") for (_, t) in board["debug"]["tools"].items())
        lines.append("""
:ref:`piodebug` - "1-click" solution for debugging with a zero configuration.

.. warning::
    You will need to install debug tool drivers depending on your system.
    Please click on compatible debug tool below for the further
    instructions and configuration information.

You can switch between debugging :ref:`debugging_tools` using
:ref:`projectconf_debug_tool` option in :ref:`projectconf`.
""")
        if has_onboard_debug:
            lines.append(
                "{name} has on-board debug probe and **IS READY** for "
                "debugging. You don't need to use/buy external debug probe.".
                format(**variables))
        else:
            lines.append(
                "{name} does not have on-board debug probe and **IS NOT "
                "READY** for debugging. You will need to use/buy one of "
                "external probe listed below.".format(**variables))
        lines.append("""
.. list-table::
  :header-rows:  1

  * - Compatible Tools
    - On-board
    - Default""")
        for (tool_name, tool_data) in sorted(board["debug"]["tools"].items()):
            lines.append("""  * - :ref:`debugging_tool_{name}`
    - {onboard}
    - {default}""".format(
                name=tool_name,
                onboard="Yes" if tool_data.get("onboard") else "",
                default="Yes" if tool_name == default_debug_tool else "",
            ))

    if board["frameworks"]:
        lines.extend(generate_frameworks_contents(board["frameworks"]))

    with open(rst_path, "w") as f:
        f.write("\n".join(lines))