mirror of
https://github.com/ansible-collections/community.general.git
synced 2026-04-05 10:13:09 +00:00
* Proper error when python-xml is missing
* use missing_required_lib to output error
* Add changelog
(cherry picked from commit 09d89da0ab)
Co-authored-by: Amin Vakil <info@aminvakil.com>
This commit is contained in:
@@ -0,0 +1,2 @@
|
||||
minor_changes:
|
||||
- zypper_repository - proper failure when python-xml is missing (https://github.com/ansible-collections/community.general/pull/939).
|
||||
@@ -123,9 +123,19 @@ EXAMPLES = '''
|
||||
runrefresh: yes
|
||||
'''
|
||||
|
||||
import traceback
|
||||
|
||||
XML_IMP_ERR = None
|
||||
try:
|
||||
from xml.dom.minidom import parseString as parseXML
|
||||
HAS_XML = True
|
||||
except ImportError:
|
||||
XML_IMP_ERR = traceback.format_exc()
|
||||
HAS_XML = False
|
||||
|
||||
from distutils.version import LooseVersion
|
||||
|
||||
from ansible.module_utils.basic import AnsibleModule
|
||||
from ansible.module_utils.basic import AnsibleModule, missing_required_lib
|
||||
|
||||
|
||||
REPO_OPTS = ['alias', 'name', 'priority', 'enabled', 'autorefresh', 'gpgcheck']
|
||||
@@ -143,7 +153,8 @@ def _parse_repos(module):
|
||||
"""parses the output of zypper --xmlout repos and return a parse repo dictionary"""
|
||||
cmd = _get_cmd('--xmlout', 'repos')
|
||||
|
||||
from xml.dom.minidom import parseString as parseXML
|
||||
if not HAS_XML:
|
||||
module.fail_json(msg=missing_required_lib("python-xml"), exception=XML_IMP_ERR)
|
||||
rc, stdout, stderr = module.run_command(cmd, check_rc=False)
|
||||
if rc == 0:
|
||||
repos = []
|
||||
|
||||
Reference in New Issue
Block a user