mirror of
https://github.com/platformio/platformio-core.git
synced 2025-07-30 18:17:13 +02:00
Dropped automatic updates of global libraries and development platforms // Resolve#4179
This commit is contained in:
@ -19,6 +19,7 @@ PlatformIO Core 5
|
|||||||
* `pio pkg exec <https://docs.platformio.org/en/latest/core/userguide/pkg/cmd_exec.html>`_ - run command from package tool (`issue #4163 <https://github.com/platformio/platformio-core/issues/4163>`_)
|
* `pio pkg exec <https://docs.platformio.org/en/latest/core/userguide/pkg/cmd_exec.html>`_ - run command from package tool (`issue #4163 <https://github.com/platformio/platformio-core/issues/4163>`_)
|
||||||
|
|
||||||
* Improved PIO Remote setup on credit-card sized computers (Raspberry Pi, BeagleBon, etc) (`issue #3865 <https://github.com/platformio/platformio-core/issues/3865>`_)
|
* Improved PIO Remote setup on credit-card sized computers (Raspberry Pi, BeagleBon, etc) (`issue #3865 <https://github.com/platformio/platformio-core/issues/3865>`_)
|
||||||
|
* Dropped automatic updates of global libraries and development platforms (`issue #4179 <https://github.com/platformio/platformio-core/issues/4179>`_)
|
||||||
|
|
||||||
5.2.5 (2022-02-10)
|
5.2.5 (2022-02-10)
|
||||||
~~~~~~~~~~~~~~~~~~
|
~~~~~~~~~~~~~~~~~~
|
||||||
|
2
docs
2
docs
Submodule docs updated: 282a997075...5a4ab6acb4
@ -35,24 +35,8 @@ def projects_dir_validate(projects_dir):
|
|||||||
|
|
||||||
|
|
||||||
DEFAULT_SETTINGS = {
|
DEFAULT_SETTINGS = {
|
||||||
"auto_update_libraries": {
|
|
||||||
"description": "Automatically update libraries (Yes/No)",
|
|
||||||
"value": False,
|
|
||||||
},
|
|
||||||
"auto_update_platforms": {
|
|
||||||
"description": "Automatically update platforms (Yes/No)",
|
|
||||||
"value": False,
|
|
||||||
},
|
|
||||||
"check_libraries_interval": {
|
|
||||||
"description": "Check for the library updates interval (days)",
|
|
||||||
"value": 7,
|
|
||||||
},
|
|
||||||
"check_platformio_interval": {
|
"check_platformio_interval": {
|
||||||
"description": "Check for the new PlatformIO interval (days)",
|
"description": "Check for the new PlatformIO Core interval (days)",
|
||||||
"value": 3,
|
|
||||||
},
|
|
||||||
"check_platforms_interval": {
|
|
||||||
"description": "Check for the platform updates interval (days)",
|
|
||||||
"value": 7,
|
"value": 7,
|
||||||
},
|
},
|
||||||
"check_prune_system_threshold": {
|
"check_prune_system_threshold": {
|
||||||
|
@ -23,18 +23,13 @@ from platformio import __version__, app, exception, fs, telemetry
|
|||||||
from platformio.cache import cleanup_content_cache
|
from platformio.cache import cleanup_content_cache
|
||||||
from platformio.clients import http
|
from platformio.clients import http
|
||||||
from platformio.commands import PlatformioCLI
|
from platformio.commands import PlatformioCLI
|
||||||
from platformio.commands.lib.command import CTX_META_STORAGE_DIRS_KEY
|
|
||||||
from platformio.commands.lib.command import lib_update as cmd_lib_update
|
|
||||||
from platformio.commands.platform import platform_update as cmd_platform_update
|
from platformio.commands.platform import platform_update as cmd_platform_update
|
||||||
from platformio.commands.system.prune import calculate_unnecessary_system_data
|
from platformio.commands.system.prune import calculate_unnecessary_system_data
|
||||||
from platformio.commands.upgrade import get_latest_version
|
from platformio.commands.upgrade import get_latest_version
|
||||||
from platformio.package.manager.core import update_core_packages
|
from platformio.package.manager.core import update_core_packages
|
||||||
from platformio.package.manager.library import LibraryPackageManager
|
|
||||||
from platformio.package.manager.platform import PlatformPackageManager
|
|
||||||
from platformio.package.manager.tool import ToolPackageManager
|
from platformio.package.manager.tool import ToolPackageManager
|
||||||
from platformio.package.meta import PackageSpec
|
from platformio.package.meta import PackageSpec
|
||||||
from platformio.package.version import pepver_to_semver
|
from platformio.package.version import pepver_to_semver
|
||||||
from platformio.platform.factory import PlatformFactory
|
|
||||||
|
|
||||||
|
|
||||||
def on_platformio_start(ctx, force, caller):
|
def on_platformio_start(ctx, force, caller):
|
||||||
@ -54,8 +49,6 @@ def on_platformio_end(ctx, result): # pylint: disable=unused-argument
|
|||||||
|
|
||||||
try:
|
try:
|
||||||
check_platformio_upgrade()
|
check_platformio_upgrade()
|
||||||
check_internal_updates(ctx, "platforms")
|
|
||||||
check_internal_updates(ctx, "libraries")
|
|
||||||
check_prune_system()
|
check_prune_system()
|
||||||
except (
|
except (
|
||||||
http.HTTPClientError,
|
http.HTTPClientError,
|
||||||
@ -212,17 +205,20 @@ def after_upgrade(ctx):
|
|||||||
|
|
||||||
|
|
||||||
def check_platformio_upgrade():
|
def check_platformio_upgrade():
|
||||||
last_check = app.get_state_item("last_check", {})
|
|
||||||
interval = int(app.get_setting("check_platformio_interval")) * 3600 * 24
|
interval = int(app.get_setting("check_platformio_interval")) * 3600 * 24
|
||||||
if (time() - interval) < last_check.get("platformio_upgrade", 0):
|
check_state = app.get_state_item("last_check", {})
|
||||||
|
last_checked_time = check_state.get("platformio_upgrade", 0)
|
||||||
|
if (time() - interval) < last_checked_time:
|
||||||
return
|
return
|
||||||
|
|
||||||
last_check["platformio_upgrade"] = int(time())
|
check_state["platformio_upgrade"] = int(time())
|
||||||
app.set_state_item("last_check", last_check)
|
app.set_state_item("last_check", check_state)
|
||||||
|
if not last_checked_time:
|
||||||
|
return
|
||||||
|
|
||||||
http.ensure_internet_on(raise_exception=True)
|
http.ensure_internet_on(raise_exception=True)
|
||||||
|
|
||||||
# Update PlatformIO's Core packages
|
# Update PlatformIO Core packages
|
||||||
update_core_packages(silent=True)
|
update_core_packages(silent=True)
|
||||||
|
|
||||||
latest_version = get_latest_version()
|
latest_version = get_latest_version()
|
||||||
@ -239,10 +235,7 @@ def check_platformio_upgrade():
|
|||||||
fg="yellow",
|
fg="yellow",
|
||||||
nl=False,
|
nl=False,
|
||||||
)
|
)
|
||||||
if os.getenv("PLATFORMIO_IDE"):
|
if os.path.join("Cellar", "platformio") in fs.get_source_dir():
|
||||||
click.secho("PlatformIO IDE Menu: Upgrade PlatformIO", fg="cyan", nl=False)
|
|
||||||
click.secho("`.", fg="yellow")
|
|
||||||
elif os.path.join("Cellar", "platformio") in fs.get_source_dir():
|
|
||||||
click.secho("brew update && brew upgrade", fg="cyan", nl=False)
|
click.secho("brew update && brew upgrade", fg="cyan", nl=False)
|
||||||
click.secho("` command.", fg="yellow")
|
click.secho("` command.", fg="yellow")
|
||||||
else:
|
else:
|
||||||
@ -256,86 +249,19 @@ def check_platformio_upgrade():
|
|||||||
click.echo("")
|
click.echo("")
|
||||||
|
|
||||||
|
|
||||||
def check_internal_updates(ctx, what): # pylint: disable=too-many-branches
|
|
||||||
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)
|
|
||||||
|
|
||||||
http.ensure_internet_on(raise_exception=True)
|
|
||||||
|
|
||||||
outdated_items = []
|
|
||||||
pm = PlatformPackageManager() if what == "platforms" else LibraryPackageManager()
|
|
||||||
for pkg in pm.get_installed():
|
|
||||||
if pkg.metadata.name in outdated_items:
|
|
||||||
continue
|
|
||||||
conds = [
|
|
||||||
pm.outdated(pkg).is_outdated(),
|
|
||||||
what == "platforms" and PlatformFactory.new(pkg).are_outdated_packages(),
|
|
||||||
]
|
|
||||||
if any(conds):
|
|
||||||
outdated_items.append(pkg.metadata.name)
|
|
||||||
|
|
||||||
if not outdated_items:
|
|
||||||
return
|
|
||||||
|
|
||||||
terminal_width, _ = shutil.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 --global" if what == "libraries" else "platform"),
|
|
||||||
fg="cyan",
|
|
||||||
nl=False,
|
|
||||||
)
|
|
||||||
click.secho(" command.\n", fg="yellow")
|
|
||||||
click.secho(
|
|
||||||
"If you want to manually check for the new versions "
|
|
||||||
"without updating, please use ",
|
|
||||||
fg="yellow",
|
|
||||||
nl=False,
|
|
||||||
)
|
|
||||||
click.secho(
|
|
||||||
"`platformio %s update --dry-run`"
|
|
||||||
% ("lib --global" if what == "libraries" else "platform"),
|
|
||||||
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_platform_update, platforms=outdated_items)
|
|
||||||
elif what == "libraries":
|
|
||||||
ctx.meta[CTX_META_STORAGE_DIRS_KEY] = [pm.package_dir]
|
|
||||||
ctx.invoke(cmd_lib_update, libraries=outdated_items)
|
|
||||||
click.echo()
|
|
||||||
|
|
||||||
telemetry.send_event(category="Auto", action="Update", label=what.title())
|
|
||||||
|
|
||||||
click.echo("*" * terminal_width)
|
|
||||||
click.echo("")
|
|
||||||
|
|
||||||
|
|
||||||
def check_prune_system():
|
def check_prune_system():
|
||||||
last_check = app.get_state_item("last_check", {})
|
|
||||||
interval = 30 * 3600 * 24 # 1 time per month
|
interval = 30 * 3600 * 24 # 1 time per month
|
||||||
if (time() - interval) < last_check.get("prune_system", time()):
|
check_state = app.get_state_item("last_check", {})
|
||||||
|
last_checked_time = check_state.get("prune_system", 0)
|
||||||
|
if (time() - interval) < last_checked_time:
|
||||||
|
return
|
||||||
|
|
||||||
|
check_state["prune_system"] = int(time())
|
||||||
|
app.set_state_item("last_check", check_state)
|
||||||
|
|
||||||
|
if not last_checked_time:
|
||||||
return
|
return
|
||||||
|
|
||||||
last_check["prune_system"] = int(time())
|
|
||||||
app.set_state_item("last_check", last_check)
|
|
||||||
threshold_mb = int(app.get_setting("check_prune_system_threshold") or 0)
|
threshold_mb = int(app.get_setting("check_prune_system_threshold") or 0)
|
||||||
if threshold_mb <= 0:
|
if threshold_mb <= 0:
|
||||||
return
|
return
|
||||||
|
Reference in New Issue
Block a user