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:
parent
7610b82e00
commit
9bbf6efe28
1 changed files with 11 additions and 9 deletions
|
|
@ -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()
|
||||||
Loading…
Add table
Add a link
Reference in a new issue