From 87921061d94eeaf75573bacc1656493997de45a1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gina=20H=C3=A4u=C3=9Fge?= Date: Mon, 12 Feb 2018 14:25:35 +0100 Subject: [PATCH] SWU: New version checkers for debugging * always_current: Always reports as current * never_current: Always reports as needing an update --- docs/bundledplugins/softwareupdate.rst | 11 +++++++++++ .../softwareupdate/version_checks/__init__.py | 2 +- .../version_checks/always_current.py | 13 +++++++++++++ .../softwareupdate/version_checks/never_current.py | 14 ++++++++++++++ 4 files changed, 39 insertions(+), 1 deletion(-) create mode 100644 src/octoprint/plugins/softwareupdate/version_checks/always_current.py create mode 100644 src/octoprint/plugins/softwareupdate/version_checks/never_current.py diff --git a/docs/bundledplugins/softwareupdate.rst b/docs/bundledplugins/softwareupdate.rst index b68a6751b..dfc837f36 100644 --- a/docs/bundledplugins/softwareupdate.rst +++ b/docs/bundledplugins/softwareupdate.rst @@ -213,6 +213,17 @@ Version checks information and whether the current version is up-to-date or not, see below for details. + * ``always_current``: Always reports that no update is necessary. Useful for debugging + software update mechanisms during development. Additional config parameters: + + * ``current_version``: Version to report for both local and remote version. + + * ``never_current``: Always reports that an update is necessary. Useful for debugging + software update mechanisms during development. Additional config parameters: + + * ``local_version``: Current local version. Defaults to ``1.0.0``. + * ``remote_version``: Remote version to offer update to. Defaults to ``1.0.1``. + .. _sec-bundledplugins-softwareupdate-configuration-updatemethods: Update methods diff --git a/src/octoprint/plugins/softwareupdate/version_checks/__init__.py b/src/octoprint/plugins/softwareupdate/version_checks/__init__.py index fb9784f53..29ce421b0 100644 --- a/src/octoprint/plugins/softwareupdate/version_checks/__init__.py +++ b/src/octoprint/plugins/softwareupdate/version_checks/__init__.py @@ -5,7 +5,7 @@ __author__ = "Gina Häußge " __license__ = 'GNU Affero General Public License http://www.gnu.org/licenses/agpl.html' __copyright__ = "Copyright (C) 2014 The OctoPrint Project - Released under terms of the AGPLv3 License" -from . import commandline, git_commit, github_commit, github_release, bitbucket_commit, python_checker +from . import commandline, git_commit, github_commit, github_release, bitbucket_commit, python_checker, never_current, always_current def log_github_ratelimit(logger, r): ratelimit = r.headers["X-RateLimit-Limit"] if "X-RateLimit-Limit" in r.headers else "?" diff --git a/src/octoprint/plugins/softwareupdate/version_checks/always_current.py b/src/octoprint/plugins/softwareupdate/version_checks/always_current.py new file mode 100644 index 000000000..c53dfada0 --- /dev/null +++ b/src/octoprint/plugins/softwareupdate/version_checks/always_current.py @@ -0,0 +1,13 @@ +# coding=utf-8 +from __future__ import absolute_import, division, print_function + +__license__ = 'GNU Affero General Public License http://www.gnu.org/licenses/agpl.html' +__copyright__ = "Copyright (C) 2018 The OctoPrint Project - Released under terms of the AGPLv3 License" + +def get_latest(target, check, online=True): + current_version = check.get("current_version", "1.0.0") + + information = dict(local=dict(name=current_version, value=current_version), + remote=dict(name=current_version, value=current_version)) + + return information, True diff --git a/src/octoprint/plugins/softwareupdate/version_checks/never_current.py b/src/octoprint/plugins/softwareupdate/version_checks/never_current.py new file mode 100644 index 000000000..247567a40 --- /dev/null +++ b/src/octoprint/plugins/softwareupdate/version_checks/never_current.py @@ -0,0 +1,14 @@ +# coding=utf-8 +from __future__ import absolute_import, division, print_function + +__license__ = 'GNU Affero General Public License http://www.gnu.org/licenses/agpl.html' +__copyright__ = "Copyright (C) 2018 The OctoPrint Project - Released under terms of the AGPLv3 License" + +def get_latest(target, check, online=True): + local_version = check.get("local_version", "1.0.0") + remote_version = check.get("remote_version", "1.0.1") + + information = dict(local=dict(name=local_version, value=local_version), + remote=dict(name=remote_version, value=remote_version)) + + return information, False