1
0
Fork 0
mirror of https://github.com/ansible-collections/community.general.git synced 2026-04-27 05:58:50 +00:00

uv_python module: improve exception handling

This commit is contained in:
Mariam Ahhttouche 2026-02-16 11:42:49 +01:00
parent 7610b82e00
commit 9bbf6efe28

View file

@ -146,17 +146,19 @@ def main():
msg="", msg="",
) )
state = module.params["state"] state = module.params["state"]
uv = UV(module)
if state == "present": try:
result["changed"], result["msg"] = uv.install_python() uv = UV(module)
elif state == "absent": if state == "present":
result["changed"], result["msg"] = uv.uninstall_python() result["changed"], result["msg"] = uv.install_python()
elif state == "latest": elif state == "absent":
result["changed"], result["msg"] = uv.upgrade_python() result["changed"], result["msg"] = uv.uninstall_python()
elif state == "latest":
module.exit_json(**result) result["changed"], result["msg"] = uv.upgrade_python()
module.exit_json(**result)
except Exception as e:
module.fail_json(msg=str(e))
if __name__ == "__main__": if __name__ == "__main__":
main() main()