Skip to content

Commit 8d0a480

Browse files
committed
Use mbed-os-tools for detect code
1 parent aeb9bcb commit 8d0a480

File tree

1 file changed

+14
-17
lines changed

1 file changed

+14
-17
lines changed

mbed/mbed.py

Lines changed: 14 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1817,23 +1817,20 @@ def detect_single_target(self, info=None):
18171817

18181818
def get_detected_targets(self):
18191819
targets = []
1820-
try:
1821-
import mbed_lstools
1822-
oldError = None
1823-
if os.name == 'nt':
1824-
oldError = ctypes.windll.kernel32.SetErrorMode(1) # Disable Windows error box temporarily. note that SEM_FAILCRITICALERRORS = 1
1825-
mbeds = mbed_lstools.create()
1826-
detect_muts_list = mbeds.list_mbeds()
1827-
if os.name == 'nt':
1828-
ctypes.windll.kernel32.SetErrorMode(oldError)
1829-
1830-
for mut in detect_muts_list:
1831-
targets.append({
1832-
'id': mut['target_id'], 'name': mut['platform_name'],
1833-
'mount': mut['mount_point'], 'serial': mut['serial_port']
1834-
})
1835-
except (IOError, ImportError, OSError):
1836-
return False
1820+
import mbed_os_tools.detect
1821+
oldError = None
1822+
if os.name == 'nt':
1823+
oldError = ctypes.windll.kernel32.SetErrorMode(1) # Disable Windows error box temporarily. note that SEM_FAILCRITICALERRORS = 1
1824+
mbeds = mbed_os_tools.detect.create()
1825+
detect_muts_list = mbeds.list_mbeds()
1826+
if os.name == 'nt':
1827+
ctypes.windll.kernel32.SetErrorMode(oldError)
1828+
1829+
for mut in detect_muts_list:
1830+
targets.append({
1831+
'id': mut['target_id'], 'name': mut['platform_name'],
1832+
'mount': mut['mount_point'], 'serial': mut['serial_port']
1833+
})
18371834

18381835
return targets
18391836

0 commit comments

Comments
 (0)