From ef885e096f3a5e104bd699cd27c6a7191cc9486c Mon Sep 17 00:00:00 2001 From: Fabio Manganiello Date: Sat, 6 Jan 2024 03:02:31 +0100 Subject: [PATCH] Added `inspect.get_pkg_managers` internal action. It will be used by the UI to put together the installation commands. --- platypush/plugins/inspect/__init__.py | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/platypush/plugins/inspect/__init__.py b/platypush/plugins/inspect/__init__.py index f1307bd16..c03edd612 100644 --- a/platypush/plugins/inspect/__init__.py +++ b/platypush/plugins/inspect/__init__.py @@ -17,7 +17,7 @@ from platypush.message.event import Event from platypush.message.response import Response from platypush.utils import get_enabled_backends, get_enabled_plugins from platypush.utils.mock import auto_mocks -from platypush.utils.manifest import Manifest, Manifests +from platypush.utils.manifest import Manifest, Manifests, PackageManagers from ._cache import Cache from ._serialize import ProcedureEncoder @@ -285,5 +285,28 @@ class InspectPlugin(Plugin): """ return list(get_enabled_backends().keys()) + @action + def get_pkg_managers(self) -> dict: + """ + Get the list of supported package managers. This is supposed to be an + internal-only method, only used by the UI to populate the install + commands. + """ + pkg_manager = PackageManagers.scan() + return { + 'items': { + pkg.value.executable: { + 'executable': pkg.value.executable, + 'install': pkg.value.install, + 'install_doc': pkg.value.install_doc, + 'uninstall': pkg.value.uninstall, + 'list': pkg.value.list, + 'default_os': pkg.value.default_os, + } + for pkg in PackageManagers + }, + 'current': pkg_manager.value.executable if pkg_manager else None, + } + # vim:sw=4:ts=4:et: