From 491270a022f23c21d33ea260f8265565eb636cf6 Mon Sep 17 00:00:00 2001 From: Sebastian Tobie Date: Sat, 15 Apr 2023 19:30:04 +0200 Subject: [PATCH] removed all try except --- plugins/module_utils/module.py | 5 +---- plugins/modules/systemd_link.py | 13 +++---------- plugins/modules/systemd_mount.py | 11 ++++------- plugins/modules/systemd_network.py | 10 +++------- 4 files changed, 11 insertions(+), 28 deletions(-) diff --git a/plugins/module_utils/module.py b/plugins/module_utils/module.py index dd2e25e..ebc20de 100644 --- a/plugins/module_utils/module.py +++ b/plugins/module_utils/module.py @@ -2,10 +2,7 @@ import pathlib from typing import Any, Callable, ClassVar, Dict, Optional, TypeVar, NoReturn, overload import ansible.module_utils.basic as basic -try: - from ansible.module_utils.generic import _sdict -except ImportError: - from generic import _sdict +from ansible.module_utils.generic import _sdict __all__ = ( "AnsibleModule", diff --git a/plugins/modules/systemd_link.py b/plugins/modules/systemd_link.py index f5c6375..49d240f 100644 --- a/plugins/modules/systemd_link.py +++ b/plugins/modules/systemd_link.py @@ -2,16 +2,9 @@ import pathlib from typing import List -try: - from ansible.module_utils.generic import SYSTEMD_NETWORK_CONFIG as SYSTEMD_PATH - from ansible.module_utils.generic import Types - from ansible.module_utils.module import SystemdUnitModule -except ImportError: - import sys - print(sys.path) - from module_utils.generic import SYSTEMD_NETWORK_CONFIG as SYSTEMD_PATH - from module_utils.generic import Types - from module_utils.module import SystemdUnitModule +from ansible.module_utils.generic import SYSTEMD_NETWORK_CONFIG as SYSTEMD_PATH +from ansible.module_utils.generic import Types +from ansible.module_utils.module import SystemdUnitModule class Module(SystemdUnitModule): """generates an systemd-networkd link""" diff --git a/plugins/modules/systemd_mount.py b/plugins/modules/systemd_mount.py index 0414ad1..bf5a248 100644 --- a/plugins/modules/systemd_mount.py +++ b/plugins/modules/systemd_mount.py @@ -1,13 +1,10 @@ #!/usr/bin/python3 import pathlib from typing import List, Optional -try: - from ansible.module_utils.generic import SYSTEMD_SERVICE_CONFIG as SYSTEMD_PATH - from ansible.module_utils.generic import Types - from ansible.module_utils.module import SystemdUnitModule -except ImportError: - import sys - print(sys.path) + +from ansible.module_utils.generic import SYSTEMD_SERVICE_CONFIG as SYSTEMD_PATH +from ansible.module_utils.generic import Types +from ansible.module_utils.module import SystemdUnitModule SYSTEMD_PATH = pathlib.Path("/etc/systemd/system") diff --git a/plugins/modules/systemd_network.py b/plugins/modules/systemd_network.py index eb6b92f..13e3cad 100644 --- a/plugins/modules/systemd_network.py +++ b/plugins/modules/systemd_network.py @@ -2,13 +2,9 @@ import pathlib from typing import List, Union -try: - from ansible.module_utils.generic import SYSTEMD_NETWORK_CONFIG as SYSTEMD_PATH - from ansible.module_utils.generic import Types - from ansible.module_utils.module import SystemdUnitModule -except ImportError: - import sys - print(sys.path) +from ansible.module_utils.generic import SYSTEMD_NETWORK_CONFIG as SYSTEMD_PATH +from ansible.module_utils.generic import Types +from ansible.module_utils.module import SystemdUnitModule def boolconvert(b: Union[bool, str]) -> str: if b is True: