Remove unused data using a new `pio system prune // Resolve #3522

This commit is contained in:
Ivan Kravets
2020-08-24 15:22:05 +03:00
parent 13db51a556
commit 3e7e9e2b3d
4 changed files with 45 additions and 10 deletions

View File

@ -30,8 +30,8 @@ PlatformIO Core 4
- Built-in fine-grained access control (role based, teams, organizations)
- Command Line Interface:
* `platformio package publish <https://docs.platformio.org/page/core/userguide/package/cmd_publish.html>`__ publish a personal or organization package
* `platformio package unpublish <https://docs.platformio.org/page/core/userguide/package/cmd_unpublish.html>`__ remove a pushed package from the registry
* `pio package publish <https://docs.platformio.org/page/core/userguide/package/cmd_publish.html>`__ publish a personal or organization package
* `pio package unpublish <https://docs.platformio.org/page/core/userguide/package/cmd_unpublish.html>`__ remove a pushed package from the registry
* Grant package access to the team members or maintainers
* New **Package Management System**
@ -46,7 +46,7 @@ PlatformIO Core 4
- Command launcher with own arguments
- Launch command with custom options declared in `"platformio.ini" <https://docs.platformio.org/page/projectconf.html>`__
- Python callback as a target (use the power of Python interpreter and PlatformIO Build API)
- List available project targets (including dev-platform specific and custom targets) with a new `platformio run --list-targets <https://docs.platformio.org/page/core/userguide/cmd_run.html#cmdoption-platformio-run-list-targets>`__ command (`issue #3544 <https://github.com/platformio/platformio-core/issues/3544>`_)
- List available project targets (including dev-platform specific and custom targets) with a new `pio run --list-targets <https://docs.platformio.org/page/core/userguide/cmd_run.html#cmdoption-platformio-run-list-targets>`__ command (`issue #3544 <https://github.com/platformio/platformio-core/issues/3544>`_)
* **PlatformIO Build System**
@ -58,12 +58,13 @@ PlatformIO Core 4
* **Miscellaneous**
- Display system-wide information using a new `platformio system info <https://docs.platformio.org/page/core/userguide/system/cmd_info.html>`__ command (`issue #3521 <https://github.com/platformio/platformio-core/issues/3521>`_)
- Dump data intended for IDE extensions/plugins using a new `platformio project idedata <https://docs.platformio.org/page/core/userguide/project/cmd_idedata.html>`__ command
- Added a new ``-e, --environment`` option to `platformio project init <https://docs.platformio.org/page/core/userguide/project/cmd_init.html#cmdoption-platformio-project-init-e>`__ command that helps to update a PlatformIO project using existing environment
- Added support for "globstar/`**`" (recursive) pattern for the different commands and configuration options (`platformio ci <https://docs.platformio.org/page/core/userguide/cmd_ci.html>`__, `src_filter <https://docs.platformio.org/page/projectconf/section_env_build.html#src-filter>`__, `check_patterns <https://docs.platformio.org/page/projectconf/section_env_check.html#check-patterns>`__, `library.json > srcFilter <https://docs.platformio.org/page/librarymanager/config.html#srcfilter>`__). Python 3.5+ is required.
- Do not generate ".travis.yml" for a new project, let the user have a choice
- Display system-wide information using a new `pio system info <https://docs.platformio.org/page/core/userguide/system/cmd_info.html>`__ command (`issue #3521 <https://github.com/platformio/platformio-core/issues/3521>`_)
- Remove unused data using a new `pio system prune <https://docs.platformio.org/page/core/userguide/system/cmd_prune.html>`__ command (`issue #3522 <https://github.com/platformio/platformio-core/issues/3522>`_)
- Dump data intended for IDE extensions/plugins using a new `pio project idedata <https://docs.platformio.org/page/core/userguide/project/cmd_idedata.html>`__ command
- Added a new ``-e, --environment`` option to `pio project init <https://docs.platformio.org/page/core/userguide/project/cmd_init.html#cmdoption-platformio-project-init-e>`__ command that helps to update a PlatformIO project using existing environment
- Added support for "globstar/`**`" (recursive) pattern for the different commands and configuration options (`pio ci <https://docs.platformio.org/page/core/userguide/cmd_ci.html>`__, `src_filter <https://docs.platformio.org/page/projectconf/section_env_build.html#src-filter>`__, `check_patterns <https://docs.platformio.org/page/projectconf/section_env_check.html#check-patterns>`__, `library.json > srcFilter <https://docs.platformio.org/page/librarymanager/config.html#srcfilter>`__). Python 3.5+ is required.
- Updated PIO Unit Testing support for Mbed framework. Added compatibility with Mbed OS 6
- Do not generate ".travis.yml" for a new project, let the user have a choice
- Do not escape compiler arguments in VSCode template on Windows
- Fixed an issue with PIO Unit Testing when running multiple environments (`issue #3523 <https://github.com/platformio/platformio-core/issues/3523>`_)

2
docs

Submodule docs updated: d01bbede6c...be04ee45c8

View File

@ -13,6 +13,7 @@
# limitations under the License.
import json
import os
import platform
import subprocess
import sys
@ -20,7 +21,7 @@ import sys
import click
from tabulate import tabulate
from platformio import __version__, compat, proc, util
from platformio import __version__, compat, fs, proc, util
from platformio.commands.system.completion import (
get_completion_install_path,
install_completion_code,
@ -30,6 +31,7 @@ from platformio.package.manager.library import LibraryPackageManager
from platformio.package.manager.platform import PlatformPackageManager
from platformio.package.manager.tool import ToolPackageManager
from platformio.project.config import ProjectConfig
from platformio.project.helpers import get_project_cache_dir
@click.group("system", short_help="Miscellaneous system commands")
@ -95,6 +97,27 @@ def system_info(json_output):
)
@cli.command("prune", short_help="Remove unused data")
@click.option("--force", "-f", is_flag=True, help="Do not prompt for confirmation")
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"
)
@cli.group("completion", short_help="Shell completion support")
def completion():
# pylint: disable=import-error,import-outside-toplevel

View File

@ -85,6 +85,17 @@ def calculate_file_hashsum(algorithm, path):
return h.hexdigest()
def calculate_folder_size(path):
assert os.path.isdir(path)
result = 0
for root, __, files in os.walk(path):
for f in files:
file_path = os.path.join(root, f)
if not os.path.islink(file_path):
result += os.path.getsize(file_path)
return result
def ensure_udev_rules():
from platformio.util import get_systype # pylint: disable=import-outside-toplevel