✨ swu: New py2 specific check overlay
Also: compatible flag. Will allow us to flag future updates as incompatible via the plugin repository.
This commit is contained in:
1 parent
0904f9917d
commit
740287528a
3 files changed
+62
-24
No files matched your search
@@ -34,7 +34,11 @@ from octoprint.server.util.flask import (
|
||||
)
|
||||
from octoprint.util import dict_merge, get_formatted_size, to_unicode
|
||||
from octoprint.util.pip import create_pip_caller
|
||||
from octoprint.util.version import get_comparable_version, get_python_version_string
|
||||
from octoprint.util.version import (
|
||||
get_comparable_version,
|
||||
get_python_version_string,
|
||||
is_python_compatible,
|
||||
)
|
||||
|
||||
from . import cli, exceptions, updaters, util, version_checks
|
||||
|
||||
@@ -372,23 +376,33 @@ class SoftwareUpdatePlugin(
|
||||
or self._overlay_cache_timestamp + self._overlay_cache_ttl < time.time()
|
||||
)
|
||||
|
||||
def _get_check_overlay(self, url):
|
||||
self._logger.info("Fetching check overlays from {}".format(url))
|
||||
try:
|
||||
r = requests.get(url, timeout=3.1)
|
||||
r.raise_for_status()
|
||||
data = r.json()
|
||||
except Exception as exc:
|
||||
self._logger.error(
|
||||
"Could not fetch check overlay from {}: {}".format(url, exc)
|
||||
)
|
||||
return {}
|
||||
else:
|
||||
return data
|
||||
|
||||
def _get_check_overlays(self, force=False):
|
||||
if self._check_overlays_stale or force:
|
||||
if self._connectivity_checker.online:
|
||||
# reload from URL
|
||||
url = self._settings.get(["check_overlay_url"])
|
||||
self._logger.info("Fetching check overlays from {}".format(url))
|
||||
try:
|
||||
r = requests.get(url, timeout=3.1)
|
||||
r.raise_for_status()
|
||||
data = r.json()
|
||||
except Exception as exc:
|
||||
self._logger.error(
|
||||
"Could not fetch check overlay from {}: {}".format(url, exc)
|
||||
self._overlay_cache = self._get_check_overlay(
|
||||
self._settings.get(["check_overlay_url"])
|
||||
)
|
||||
if is_python_compatible("<3"):
|
||||
data = self._get_check_overlay(
|
||||
self._settings.get(["check_overlay_py2_url"])
|
||||
)
|
||||
self._overlay_cache = octoprint.util.dict_merge(
|
||||
self._overlay_cache, data
|
||||
)
|
||||
self._overlay_cache = {}
|
||||
else:
|
||||
self._overlay_cache = data
|
||||
|
||||
else:
|
||||
self._logger.info("Not fetching check overlays, we are offline")
|
||||
@@ -535,6 +549,7 @@ class SoftwareUpdatePlugin(
|
||||
"ignore_throttled": False,
|
||||
"minimum_free_storage": 150,
|
||||
"check_overlay_url": "https://plugins.octoprint.org/update_check_overlay.json",
|
||||
"check_overlay_py2_url": "https://plugins.octoprint.org/update_check_overlay_py2.json",
|
||||
"check_overlay_ttl": 6 * 60,
|
||||
"credentials": {
|
||||
"github": None,
|
||||
@@ -1336,6 +1351,7 @@ class SoftwareUpdatePlugin(
|
||||
)
|
||||
|
||||
target_disabled = populated_check.get("disabled", False)
|
||||
target_compatible = populated_check.get("compatible", True)
|
||||
update_available = update_available or (
|
||||
target_update_available and not target_disabled
|
||||
)
|
||||
@@ -1385,6 +1401,7 @@ class SoftwareUpdatePlugin(
|
||||
"online": target_online,
|
||||
"error": target_error,
|
||||
"disabled": target_disabled,
|
||||
"compatible": target_compatible,
|
||||
"releaseChannels": {},
|
||||
}
|
||||
|
||||
@@ -1490,6 +1507,9 @@ class SoftwareUpdatePlugin(
|
||||
update_available = False
|
||||
error = None
|
||||
|
||||
disabled = check.get("disabled", False)
|
||||
compatible = check.get("compatible", True)
|
||||
|
||||
try:
|
||||
version_checker = self._get_version_checker(target, check)
|
||||
information, is_current = version_checker.get_latest(
|
||||
@@ -1506,7 +1526,7 @@ class SoftwareUpdatePlugin(
|
||||
)
|
||||
del self._version_cache[target]
|
||||
self._version_cache_dirty = True
|
||||
elif not is_current:
|
||||
elif not is_current and compatible:
|
||||
update_available = True
|
||||
except exceptions.CannotCheckOffline:
|
||||
update_possible = False
|
||||
@@ -1544,15 +1564,15 @@ class SoftwareUpdatePlugin(
|
||||
else:
|
||||
try:
|
||||
updater = self._get_updater(target, check)
|
||||
update_possible = updater.can_perform_update(target, check, online=online)
|
||||
update_possible = compatible and updater.can_perform_update(
|
||||
target, check, online=online
|
||||
)
|
||||
except Exception:
|
||||
self._logger.exception(
|
||||
"Error while checking if {} can be updated".format(target)
|
||||
)
|
||||
update_possible = False
|
||||
|
||||
disabled = check.get("disabled", False)
|
||||
|
||||
self._version_cache[target] = {
|
||||
"timestamp": time.time(),
|
||||
"hash": current_hash,
|
||||
@@ -1562,6 +1582,7 @@ class SoftwareUpdatePlugin(
|
||||
"online": online,
|
||||
"error": error,
|
||||
"disabled": disabled,
|
||||
"compatible": compatible,
|
||||
}
|
||||
self._version_cache_dirty = True
|
||||
return information, update_available, update_possible, online, error
|
||||
@@ -1643,7 +1664,7 @@ class SoftwareUpdatePlugin(
|
||||
continue
|
||||
check = checks[target]
|
||||
|
||||
if "enabled" in check and not check["enabled"]:
|
||||
if not check.get("enabled", True) or not check.get("compatible", True):
|
||||
continue
|
||||
|
||||
if target not in check_targets:
|
||||
@@ -1736,8 +1757,17 @@ class SoftwareUpdatePlugin(
|
||||
|
||||
if not update_possible:
|
||||
self._logger.warning(
|
||||
"Cannot perform update for %s, update type is not fully configured"
|
||||
% target
|
||||
"Cannot perform update for {}, update type is not fully configured".format(
|
||||
target
|
||||
)
|
||||
)
|
||||
return False, None
|
||||
|
||||
if not information.get("compatible", True):
|
||||
self._logger.warning(
|
||||
"Cannot perform update for {}, update is reported as incompatible".format(
|
||||
target
|
||||
)
|
||||
)
|
||||
return False, None
|
||||
|
||||
|
||||
@@ -386,7 +386,11 @@ $(function () {
|
||||
|
||||
text += "<ul class='fa-ul'>";
|
||||
_.each(self.versions.items(), function (update_info) {
|
||||
if (update_info.updateAvailable && !update_info.disabled) {
|
||||
if (
|
||||
update_info.updateAvailable &&
|
||||
!update_info.disabled &&
|
||||
update_info.compatible
|
||||
) {
|
||||
text +=
|
||||
"<li>" +
|
||||
"<i class='fa fa-li " +
|
||||
|
||||
@@ -92,18 +92,22 @@
|
||||
<tbody data-bind="foreach: versions.paginatedItems">
|
||||
<tr data-bind="attr: {title: displayName}">
|
||||
<td class="settings_plugin_softwareupdate_column_update">
|
||||
<a href="javascript:void(0)" data-bind="click: toggleDisabled"><i class="far" data-bind="css: { muted: !updateAvailable, 'fa-bell': !disabled, 'fa-bell-slash': disabled }" title="{{ _('Update available')|edq }}"></i></a><br />
|
||||
<a href="javascript:void(0)" data-bind="visible: compatible, click: toggleDisabled"><i class="far" data-bind="css: { muted: !updateAvailable, 'fa-bell': !disabled, 'fa-bell-slash': disabled }" title="{{ _('Update available')|edq }}"></i></a>
|
||||
<span data-bind="visible: !compatible" class="muted"><i class="fas fa-power-off" title="{{ _('Not compatible') }}|edq"></i></span>
|
||||
</td>
|
||||
<td class="settings_plugin_softwareupdate_column_information">
|
||||
<a href="javascript:void(0)" data-bind="click: function() { $root.update(false, [$data]) }, visible: $root.enableUpdate() && updateAvailable && updatePossible" class="btn btn-primary pull-right">{{ _('Update') }}</a>
|
||||
<strong data-bind="text: displayName"></strong>: <span data-bind="text: displayVersion"></span> <span data-bind="invisible: updatePossible"><i class="fas fa-exclamation-triangle" data-bind="css: {'fa-unlink': !online && information && information.needs_online, 'fa-exclamation-triangle': !(!online && information && information.needs_online)}, attr: {title: $root.iconTitleForEntry($data)}"></i></span><br>
|
||||
<small class="muted">
|
||||
<small data-bind="visible: compatible" class="muted">
|
||||
<span data-bind="visible: releaseChannels && releaseChannels.available" class="line">{{ _('Release Channel:') }} <select class="settings_plugin_softwareupdate_release_channel" data-bind="visible: releaseChannels && releaseChannels.available, value: releaseChannels.current, options: releaseChannels.available, optionsText: 'name', optionsValue: 'channel'"></select> <a href="https://faq.octoprint.org/using-release-channels" target="_blank"><i class="fas fa-question-circle"></i></a></span>
|
||||
<span class="line">{{ _('Installed:') }} <span data-bind="text: information.local.name"></span></span>
|
||||
<span class="line">{{ _('Available:') }} <span data-bind="text: information.remote.name"></span></span>
|
||||
<span class="line" data-bind="visible: releaseNotes">{{ _('Release Notes:') }} <a data-bind="attr: {href: releaseNotes}, text: releaseNotes" target="_blank" rel="noreferrer noopener"></a></span>
|
||||
<span class="line text-error" data-bind="visible: error, text: $root.errorTextForEntry($data)"></span>
|
||||
</small>
|
||||
<small data-bind="visible: !compatible">
|
||||
<span class="line text-error">{{ _('Newer versions of this plugin are not compatible to this setup.') }}</span>
|
||||
</small>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
|
||||
Reference in new issue
Block a user