Skip to content

Commit

Permalink
Merge branch 'master' into hani-iot
Browse files Browse the repository at this point in the history
  • Loading branch information
madchutney authored Dec 17, 2019
2 parents e989416 + bf3614c commit 888842b
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 6 deletions.
4 changes: 4 additions & 0 deletions azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,10 @@ jobs:
-
script: "python -m pip install --upgrade pip && pip install -r test_requirements.txt"
displayName: "Install mbed-os test dependencies"
-
script: "pip install lxml"
env: { STATIC_DEPS: true }
displayName: "Install lxml separately on Linux/MacOS"
-
script: 'pip install --user "urllib3<1.25"'
displayName: "Fix dependency issue for requests package"
Expand Down
2 changes: 1 addition & 1 deletion packages/mbed-ls/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
PrettyTable>=0.7.2
mbed-os-tools>=0.0.9,<0.1.0
mbed-os-tools>=0.0.9,<0.1.0
3 changes: 3 additions & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,6 @@ junit-xml>=1.0,<2.0
lockfile
six>=1.0,<2.0
colorama>=0.3,<0.5
# When using beautiful soup, the XML parser needs to be installed independently. It is only needed on macOs though.
beautifulsoup4
lxml; sys_platform == 'darwin'
19 changes: 14 additions & 5 deletions src/mbed_os_tools/detect/darwin.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
import subprocess
import platform

from bs4 import BeautifulSoup

try:
from plistlib import loads
except ImportError:
Expand All @@ -40,7 +42,13 @@ def _plist_from_popen(popen):
if not out:
return []
try:
return loads(out)
# 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 Expand Up @@ -85,9 +93,9 @@ def _dfs_usb_info(obj, parents):
"""
output = {}
if (
"BSD Name" in obj
and obj["BSD Name"].startswith("disk")
and mbed_volume_name_match.search(obj["IORegistryEntryName"])
"BSD Name" in obj
and obj["BSD Name"].startswith("disk")
and mbed_volume_name_match.search(obj["IORegistryEntryName"])
):
disk_id = obj["BSD Name"]
usb_info = {"serial": None, "vendor_id": None, "product_id": None, "tty": None}
Expand Down Expand Up @@ -177,12 +185,13 @@ def _volumes(self):
if self.mac_version >= 10.11:
cmp_par = "-c"

usb_tree = []
for usb_controller in usb_controllers:
ioreg_usb = subprocess.Popen(
["ioreg", "-a", "-r", cmp_par, usb_controller, "-l"],
stdout=subprocess.PIPE,
)
usb_tree = _plist_from_popen(ioreg_usb)
usb_tree.extend(_plist_from_popen(ioreg_usb))

r = {}

Expand Down

0 comments on commit 888842b

Please sign in to comment.