SWU: Add sleep_a_bit updater for testing
This commit is contained in:
1 parent
f8079c3f50
commit
8148fd7679
4 files changed
+29
-2
No files matched your search
@@ -243,6 +243,9 @@ Update methods
|
||||
* ``python_updater``: Can only be specified by plugins through the
|
||||
:ref:`hook <sec-bundledplugins-softwareupdate-hooks>`. A python callable
|
||||
which performs the update, see below for details.
|
||||
* ``sleep_a_bit``: Does nothing but block for a configurable ``duration`` and log
|
||||
a countdown in the meantime. Useful for debugging software update mechanisms
|
||||
during development.
|
||||
|
||||
.. note::
|
||||
|
||||
|
||||
@@ -1113,7 +1113,8 @@ class SoftwareUpdatePlugin(octoprint.plugin.BlueprintPlugin,
|
||||
|
||||
mapping = dict(update_script=updaters.update_script,
|
||||
pip=updaters.pip,
|
||||
python_updater=updaters.python_updater)
|
||||
python_updater=updaters.python_updater,
|
||||
sleep_a_bit=updaters.sleep_a_bit)
|
||||
|
||||
method = self._get_update_method(target, check, valid_methods=mapping.keys())
|
||||
return mapping[method]
|
||||
|
||||
@@ -5,4 +5,4 @@ __author__ = "Gina Häußge <osd@foosel.net>"
|
||||
__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 pip, python_updater, update_script
|
||||
from . import pip, python_updater, update_script, sleep_a_bit
|
||||
@@ -0,0 +1,23 @@
|
||||
# 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"
|
||||
|
||||
|
||||
import monotonic
|
||||
import time
|
||||
|
||||
def can_perform_update(target, check, online=True):
|
||||
return True
|
||||
|
||||
|
||||
def perform_update(target, check, target_version, log_cb=None, online=True):
|
||||
duration = check.get("duration", 30)
|
||||
|
||||
now = monotonic.monotonic()
|
||||
end = now + duration
|
||||
while now < end:
|
||||
log_cb(["{}s left...".format(end - now)], prefix=">", stream="output")
|
||||
time.sleep(5)
|
||||
now = monotonic.monotonic()
|
||||
Reference in new issue
Block a user