Added inspect.get_pkg_managers internal action.

It will be used by the UI to put together the installation commands.
This commit is contained in:
Fabio Manganiello 2024-01-06 03:02:31 +01:00
parent e1b6be7673
commit ef885e096f
Signed by untrusted user: blacklight
GPG key ID: D90FBA7F76362774

View file

@ -17,7 +17,7 @@ from platypush.message.event import Event
from platypush.message.response import Response from platypush.message.response import Response
from platypush.utils import get_enabled_backends, get_enabled_plugins from platypush.utils import get_enabled_backends, get_enabled_plugins
from platypush.utils.mock import auto_mocks 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 ._cache import Cache
from ._serialize import ProcedureEncoder from ._serialize import ProcedureEncoder
@ -285,5 +285,28 @@ class InspectPlugin(Plugin):
""" """
return list(get_enabled_backends().keys()) 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: # vim:sw=4:ts=4:et: