mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-08-06 14:14:22 -07:00
pipx/pipx_info: multiple fixes (#9044)
* pipx_info: factored process_list out * pipx_info: no need to pass param to _list * pipx_info: minor adjustment * pipx mod utils: make_process_list parameters * fix test for state=install_all * fix assertions * pipx tests: fix detection of pipx 1.7.0 * pipx: use make_process_output * add testcase * pipx: remove import json * pinned in pipx list is not always there * Update plugins/modules/pipx_info.py Co-authored-by: Felix Fontein <felix@fontein.de> * remove ensurepath and --user from pipx install * add changelog frag * Update changelogs/fragments/9044-pipx-fixes.yml Co-authored-by: Felix Fontein <felix@fontein.de> * Update changelogs/fragments/9044-pipx-fixes.yml * Update changelogs/fragments/9044-pipx-fixes.yml Co-authored-by: Felix Fontein <felix@fontein.de> * Update changelogs/fragments/9044-pipx-fixes.yml Co-authored-by: Felix Fontein <felix@fontein.de> --------- Co-authored-by: Felix Fontein <felix@fontein.de>
This commit is contained in:
parent
c8410a924e
commit
2429e228a4
12 changed files with 165 additions and 176 deletions
|
@ -191,10 +191,8 @@ EXAMPLES = """
|
|||
"""
|
||||
|
||||
|
||||
import json
|
||||
|
||||
from ansible_collections.community.general.plugins.module_utils.module_helper import StateModuleHelper
|
||||
from ansible_collections.community.general.plugins.module_utils.pipx import pipx_runner, pipx_common_argspec
|
||||
from ansible_collections.community.general.plugins.module_utils.pipx import pipx_runner, pipx_common_argspec, make_process_list
|
||||
|
||||
from ansible.module_utils.facts.compat import ansible_facts
|
||||
|
||||
|
@ -251,26 +249,14 @@ class PipX(StateModuleHelper):
|
|||
use_old_vardict = False
|
||||
|
||||
def _retrieve_installed(self):
|
||||
def process_list(rc, out, err):
|
||||
if not out:
|
||||
return {}
|
||||
name = _make_name(self.vars.name, self.vars.suffix)
|
||||
output_process = make_process_list(self, include_injected=True, name=name)
|
||||
installed = self.runner('_list global', output_process=output_process).run()
|
||||
|
||||
results = {}
|
||||
raw_data = json.loads(out)
|
||||
for venv_name, venv in raw_data['venvs'].items():
|
||||
results[venv_name] = {
|
||||
'version': venv['metadata']['main_package']['package_version'],
|
||||
'injected': {k: v['package_version'] for k, v in venv['metadata']['injected_packages'].items()},
|
||||
}
|
||||
return results
|
||||
|
||||
installed = self.runner('_list', output_process=process_list).run(_list=1)
|
||||
|
||||
if self.vars.name is not None:
|
||||
name = _make_name(self.vars.name, self.vars.suffix)
|
||||
app_list = installed.get(name)
|
||||
if name is not None:
|
||||
app_list = [app for app in installed if app['name'] == name]
|
||||
if app_list:
|
||||
return {name: app_list}
|
||||
return {name: app_list[0]}
|
||||
else:
|
||||
return {}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue