Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 11 additions & 6 deletions src/mbed_os_tools/detect/darwin.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,13 +42,18 @@ def _plist_from_popen(popen):
if not out:
return []
try:
# Beautiful soup ensures the XML is properly formed after it is parsed
# so that it can be used by other less lenient commands without problems
xml_representation = BeautifulSoup(out.decode('utf8'), 'xml')
if not xml_representation.get_text():
# The output is not in the XML format
try:
# Try simple and fast first if this fails fall back to the slower but better process
return loads(out)
return loads(xml_representation.decode().encode('utf8'))
except ExpatError:
# Beautiful soup ensures the XML is properly formed after it is parsed
# so that it can be used by other less lenient commands without problems
xml_representation = BeautifulSoup(out.decode('utf8'), 'xml')

if not xml_representation.get_text():
# The output is not in the XML format
return loads(out)
return loads(xml_representation.decode().encode('utf8'))
except ExpatError:
return []

Expand Down