Fix exception issue in junos_config (#24066)

ParseError execption is added to ElementTree
in py2.7. Prior to py2.7 need catch ExpatError
execption
(cherry picked from commit 7d710882a8)

* Fix python version check issue (#24063)

Fix python version check issue
(cherry picked from commit 1f7c2c63c2)
pull/24091/head
Ganesh Nalawade 9 years ago committed by GitHub
parent b4380432f6
commit ab79e96c3c

@ -175,6 +175,7 @@ backup_path:
"""
import re
import json
import sys
from xml.etree import ElementTree
@ -185,6 +186,12 @@ from ansible.module_utils.junos import check_args as junos_check_args
from ansible.module_utils.netconf import send_request
from ansible.module_utils.six import string_types
if sys.version_info < (2, 7):
from xml.parsers.expat import ExpatError
ParseError = ExpatError
else:
ParseError = ElementTree.ParseError
USE_PERSISTENT_CONNECTION = True
DEFAULT_COMMENT = 'configured by junos_config'
@ -207,7 +214,7 @@ def guess_format(config):
try:
ElementTree.fromstring(config)
return 'xml'
except ElementTree.ParseError:
except ParseError:
pass
if config.startswith('set') or config.startswith('delete'):

Loading…
Cancel
Save