✨ swu: new pip option "force_reinstall"
If set to true, will perform a double install, once normal (to gather required dependencies), once with --force-reinstall and --no-deps (to force a reinstall of the package itself). See #4363
This commit is contained in:
1 parent
4b557e6aea
commit
34c46f6a1b
6 files changed
+26
-8
No files matched your search
@@ -338,6 +338,15 @@ supported:
|
||||
Additional config parameters:
|
||||
|
||||
* ``pip``: The URL to use for installing. Presence implies ``method: pip``.
|
||||
* ``pip_command``: The command to use for installing. Defaults to the ``pip`` instance belong to OctoPrint's environment.
|
||||
* ``pip_cwd``: The working directory to use for installing. Defaults to the current working directory.
|
||||
* ``force_reinstall``: Whether to force reinstallation of the package. Defaults to ``false``. Helpful
|
||||
for development and version checks that don't guarantee a Python package version change (e.g. commit based
|
||||
version checks like ``git_commit``, ``github_commit``, ``bitbucket_commit``).
|
||||
|
||||
.. versionchanged:: 1.8.0
|
||||
|
||||
Added ``force_reinstall`` parameter.
|
||||
|
||||
* ``single_file_plugin``: Update a single file plugin by re-downloading it from a configured URL.
|
||||
Additional config parameters:
|
||||
|
||||
@@ -2074,7 +2074,12 @@ class SoftwareUpdatePlugin(
|
||||
raise exceptions.UnknownUpdateType()
|
||||
|
||||
update_result = updater.perform_update(
|
||||
target, populated_check, target_version, log_cb=self._log, online=online
|
||||
target,
|
||||
populated_check,
|
||||
target_version,
|
||||
log_cb=self._log,
|
||||
online=online,
|
||||
force=force,
|
||||
)
|
||||
target_result = ("success", update_result)
|
||||
self._logger.info(
|
||||
|
||||
@@ -71,6 +71,8 @@ def perform_update(target, check, target_version, log_cb=None, online=True, forc
|
||||
if not online and not check.get("offline", False):
|
||||
raise exceptions.CannotUpdateOffline()
|
||||
|
||||
force = force or check.get("force_reinstall", False)
|
||||
|
||||
pip_caller = _get_pip_caller(command=pip_command)
|
||||
if pip_caller is None:
|
||||
raise exceptions.UpdateError("Can't run pip", None)
|
||||
|
||||
@@ -15,24 +15,26 @@ def can_perform_update(target, check, online=True):
|
||||
)
|
||||
|
||||
|
||||
def perform_update(target, check, target_version, log_cb=None, online=True):
|
||||
def perform_update(target, check, target_version, log_cb=None, online=True, force=False):
|
||||
from ..exceptions import CannotUpdateOffline
|
||||
|
||||
if not online and not check("offline", False):
|
||||
raise CannotUpdateOffline()
|
||||
|
||||
kwargs = {"log_cb": log_cb, "online": online, "force": force}
|
||||
try:
|
||||
return check["python_updater"].perform_update(
|
||||
target, check, target_version, log_cb=log_cb, online=online
|
||||
target, check, target_version, **kwargs
|
||||
)
|
||||
except Exception:
|
||||
import inspect
|
||||
|
||||
args, _, _, _ = inspect.getargspec(check["python_updater"].perform_update)
|
||||
if "online" not in args:
|
||||
# old python_updater footprint, simply leave out the online parameter
|
||||
if not all(k in args for k in kwargs):
|
||||
# old python_updater footprint, leave out what it doesn't understand
|
||||
old_kwargs = {k: v for k, v in kwargs.items() if k in args}
|
||||
return check["python_updater"].perform_update(
|
||||
target, check, target_version, log_cb=log_cb
|
||||
target, check, target_version, **old_kwargs
|
||||
)
|
||||
|
||||
# some other error, raise again
|
||||
|
||||
@@ -14,7 +14,7 @@ def can_perform_update(target, check, online=True):
|
||||
return True
|
||||
|
||||
|
||||
def perform_update(target, check, target_version, log_cb=None, online=True):
|
||||
def perform_update(target, check, target_version, log_cb=None, online=True, force=False):
|
||||
duration = check.get("duration", 30)
|
||||
|
||||
now = monotonic_time()
|
||||
|
||||
@@ -55,7 +55,7 @@ def can_perform_update(target, check, online=True):
|
||||
)
|
||||
|
||||
|
||||
def perform_update(target, check, target_version, log_cb=None, online=True):
|
||||
def perform_update(target, check, target_version, log_cb=None, online=True, force=False):
|
||||
logger = logging.getLogger("octoprint.plugins.softwareupdate.updaters.update_script")
|
||||
|
||||
if not online and not check("offline", False):
|
||||
|
||||
Reference in new issue
Block a user