Skip to content

Commit e4b55dd

Browse files
committed
Removed get_mounted_details_txt from test_api.py
Fixed minor typos in test_api.py Added get_interface_version to detect_targets
1 parent 7ff57c4 commit e4b55dd

File tree

2 files changed

+28
-14
lines changed

2 files changed

+28
-14
lines changed

tools/detect_targets.py

Lines changed: 27 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,13 @@
3131
# Imports related to mbed build api
3232
from tools.build_api import mcu_toolchain_matrix
3333
from tools.test_api import get_autodetected_MUTS_list
34-
from tools.test_api import get_mounted_details_txt
34+
from tools.test_api import get_module_avail
3535
from argparse import ArgumentParser
3636

37+
try:
38+
import mbed_lstools
39+
except:
40+
pass
3741

3842
def main():
3943
"""Entry Point"""
@@ -76,17 +80,17 @@ def main():
7680
count = 0
7781
for mut in muts.values():
7882
if re.match(mcu_filter, mut['mcu']):
79-
# Grab additional target details about the mut
80-
details_txt = get_mounted_details_txt(mut['disk'])
83+
interface_version = get_interface_version(mut['disk'])
8184
print ""
82-
print "[mbed] Detected %s, port %s, mounted %s, interface version %s" % \
83-
(mut['mcu'], mut['port'], mut['disk'], details_txt['Interface Version'])
85+
print "[mbed] Detected %s, port %s, mounted %s, interface version %s:" % \
86+
(mut['mcu'], mut['port'], mut['disk'], interface_version)
87+
8488
print "[mbed] Supported toolchains for %s" % mut['mcu']
8589
print mcu_toolchain_matrix(platform_filter=mut['mcu'])
8690
count += 1
8791

8892
if count == 0:
89-
print "[mbed] No mbed targets where detected on your system."
93+
print "[mbed] No mbed targets were detected on your system."
9094

9195
except KeyboardInterrupt:
9296
print "\n[CTRL+c] exit"
@@ -95,6 +99,23 @@ def main():
9599
traceback.print_exc(file=sys.stdout)
96100
print "[ERROR] %s" % str(exc)
97101
sys.exit(1)
102+
103+
def get_interface_version(mount_point):
104+
""" Function returns interface version from the target mounted on the specified mount point
105+
mount_point = mut['port']
106+
@param mount_point Name of disk where platform is connected to host machine.
107+
"""
108+
if get_module_avail('mbed_lstools'):
109+
mbeds = mbed_lstools.create()
110+
details_txt = mbeds.get_details_txt(mount_point)
111+
112+
if 'Interface Version' in details_txt:
113+
return details_txt['Interface Version']
114+
115+
elif 'Version' in details_txt:
116+
return details_txt['Version']
117+
118+
return 'unknown'
98119

99120
if __name__ == '__main__':
100121
main()

tools/test_api.py

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1643,17 +1643,10 @@ def detect_database_verbose(db_url):
16431643

16441644

16451645
def get_module_avail(module_name):
1646-
""" This function returns True if module_name is already impored module
1646+
""" This function returns True if module_name is already imported module
16471647
"""
16481648
return module_name in sys.modules.keys()
16491649

1650-
def get_mounted_details_txt(mount_point):
1651-
""" Function returns object containing details.txt information from the specified mount point
1652-
@param mount_point Name of disk where platform is connected to host machine.
1653-
"""
1654-
mbeds = mbed_lstools.create()
1655-
return mbeds.get_details_txt(mount_point)
1656-
16571650
def get_autodetected_MUTS_list(platform_name_filter=None):
16581651
oldError = None
16591652
if os.name == 'nt':

0 commit comments

Comments
 (0)