mirror of
https://github.com/ansible-collections/community.general.git
synced 2026-04-30 07:28:52 +00:00
Reformat everything.
This commit is contained in:
parent
3f2213791a
commit
340ff8586d
1008 changed files with 61301 additions and 58309 deletions
|
|
@ -101,40 +101,37 @@ from ansible.module_utils.facts.packages import CLIMgr
|
|||
|
||||
|
||||
class PIP(CLIMgr):
|
||||
|
||||
def __init__(self, pip, module):
|
||||
|
||||
self.CLI = pip
|
||||
self.module = module
|
||||
|
||||
def list_installed(self):
|
||||
rc, out, err = self.module.run_command([self._cli, 'list', '-l', '--format=json'])
|
||||
rc, out, err = self.module.run_command([self._cli, "list", "-l", "--format=json"])
|
||||
if rc != 0:
|
||||
raise Exception(f"Unable to list packages rc={rc} : {err}")
|
||||
return json.loads(out)
|
||||
|
||||
def get_package_details(self, package):
|
||||
package['source'] = self.CLI
|
||||
package["source"] = self.CLI
|
||||
return package
|
||||
|
||||
|
||||
def main():
|
||||
|
||||
# start work
|
||||
module = AnsibleModule(
|
||||
argument_spec=dict(
|
||||
clients=dict(type='list', elements='path', default=['pip']),
|
||||
clients=dict(type="list", elements="path", default=["pip"]),
|
||||
),
|
||||
supports_check_mode=True)
|
||||
supports_check_mode=True,
|
||||
)
|
||||
packages = {}
|
||||
results = {'packages': {}}
|
||||
clients = module.params['clients']
|
||||
results = {"packages": {}}
|
||||
clients = module.params["clients"]
|
||||
|
||||
found = 0
|
||||
for pip in clients:
|
||||
|
||||
if not os.path.basename(pip).startswith('pip'):
|
||||
module.warn(f'Skipping invalid pip client: {pip}')
|
||||
if not os.path.basename(pip).startswith("pip"):
|
||||
module.warn(f"Skipping invalid pip client: {pip}")
|
||||
continue
|
||||
try:
|
||||
pip_mgr = PIP(pip, module)
|
||||
|
|
@ -142,16 +139,16 @@ def main():
|
|||
found += 1
|
||||
packages[pip] = pip_mgr.get_packages()
|
||||
except Exception as e:
|
||||
module.warn(f'Failed to retrieve packages with {pip}: {e}')
|
||||
module.warn(f"Failed to retrieve packages with {pip}: {e}")
|
||||
continue
|
||||
|
||||
if found == 0:
|
||||
module.fail_json(msg=f'Unable to use any of the supplied pip clients: {clients}')
|
||||
module.fail_json(msg=f"Unable to use any of the supplied pip clients: {clients}")
|
||||
|
||||
# return info
|
||||
results['packages'] = packages
|
||||
results["packages"] = packages
|
||||
module.exit_json(**results)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue