From 3bf8b1d1c99cf5354cb7687d4a8669a144f3f90d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mariusz=20Kry=C5=84ski?= Date: Sun, 19 Jan 2020 18:57:54 +0100 Subject: [PATCH] jenkins_job module: fix for python3 (#54958) --- .../modules/web_infrastructure/jenkins_job.py | 17 ++--------------- 1 file changed, 2 insertions(+), 15 deletions(-) diff --git a/lib/ansible/modules/web_infrastructure/jenkins_job.py b/lib/ansible/modules/web_infrastructure/jenkins_job.py index 69ab1d541d3..d637011369d 100644 --- a/lib/ansible/modules/web_infrastructure/jenkins_job.py +++ b/lib/ansible/modules/web_infrastructure/jenkins_job.py @@ -20,7 +20,6 @@ description: - Manage Jenkins jobs by using Jenkins REST API. requirements: - "python-jenkins >= 0.4.12" - - "lxml >= 3.3.3" version_added: "2.2" author: "Sergio Millan Rodriguez (@sermilrod)" options: @@ -147,6 +146,7 @@ url: ''' import traceback +import xml.etree.ElementTree as ET JENKINS_IMP_ERR = None try: @@ -156,14 +156,6 @@ except ImportError: JENKINS_IMP_ERR = traceback.format_exc() python_jenkins_installed = False -LXML_IMP_ERR = None -try: - from lxml import etree as ET - python_lxml_installed = True -except ImportError: - LXML_IMP_ERR = traceback.format_exc() - python_lxml_installed = False - from ansible.module_utils.basic import AnsibleModule, missing_required_lib from ansible.module_utils._text import to_native @@ -334,14 +326,9 @@ def test_dependencies(module): url="https://python-jenkins.readthedocs.io/en/latest/install.html"), exception=JENKINS_IMP_ERR) - if not python_lxml_installed: - module.fail_json( - msg=missing_required_lib("lxml", url="https://lxml.de/installation.html"), - exception=LXML_IMP_ERR) - def job_config_to_string(xml_str): - return ET.tostring(ET.fromstring(xml_str)) + return ET.tostring(ET.fromstring(xml_str)).decode('ascii') def main():