mirror of
https://github.com/valitydev/salt.git
synced 2024-11-07 00:55:19 +00:00
Add secondary exception handler for malformed plists.
This commit is contained in:
parent
ae6f49b0b1
commit
fd62b336dc
@ -340,15 +340,21 @@ def _available_services(refresh=False):
|
||||
|
||||
except Exception:
|
||||
# If plistlib is unable to read the file we'll need to use
|
||||
# the system provided plutil program to do the conversion
|
||||
# the system provided plutil program to attempt conversion
|
||||
# from binary.
|
||||
cmd = '/usr/bin/plutil -convert xml1 -o - -- "{0}"'.format(
|
||||
true_path)
|
||||
try:
|
||||
plist_xml = __salt__['cmd.run'](cmd)
|
||||
if six.PY2:
|
||||
plist = plistlib.readPlistFromString(plist_xml)
|
||||
else:
|
||||
plist = plistlib.loads(
|
||||
salt.utils.stringutils.to_bytes(plist_xml))
|
||||
except Exception:
|
||||
# If the file is actually just invalid XML, move on to
|
||||
# the next one.
|
||||
continue
|
||||
|
||||
try:
|
||||
_available_services[plist.Label.lower()] = {
|
||||
|
Loading…
Reference in New Issue
Block a user