Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Diff: detect_targets.py
- Revision:
- 43:2a7da56ebd24
- Parent:
- 41:2a77626a4c21
--- a/detect_targets.py Mon Nov 06 13:17:14 2017 -0600
+++ b/detect_targets.py Tue Sep 25 13:43:09 2018 -0500
@@ -15,6 +15,7 @@
See the License for the specific language governing permissions and
limitations under the License.
"""
+from __future__ import print_function
import sys
import os
import re
@@ -67,8 +68,8 @@
# Only prints matrix of supported toolchains
if options.supported_toolchains:
- print mcu_toolchain_matrix(
- platform_filter=options.general_filter_regex)
+ print(mcu_toolchain_matrix(
+ platform_filter=options.general_filter_regex))
exit(0)
# If auto_detect attribute is present, we assume other auto-detection
@@ -79,25 +80,25 @@
count = 0
for mut in muts.values():
- if re.match(mcu_filter, mut['mcu']):
+ if re.match(mcu_filter, mut['mcu'] or "Unknown"):
interface_version = get_interface_version(mut['disk'])
- print ""
- print "[mbed] Detected %s, port %s, mounted %s, interface version %s:" % \
- (mut['mcu'], mut['port'], mut['disk'], interface_version)
-
- print "[mbed] Supported toolchains for %s" % mut['mcu']
- print mcu_toolchain_matrix(platform_filter=mut['mcu'])
+ print("")
+ print("[mbed] Detected %s, port %s, mounted %s, interface "
+ "version %s:" %
+ (mut['mcu'], mut['port'], mut['disk'], interface_version))
+ print("[mbed] Supported toolchains for %s" % mut['mcu'])
+ print(mcu_toolchain_matrix(platform_filter=mut['mcu']))
count += 1
if count == 0:
- print "[mbed] No mbed targets were detected on your system."
+ print("[mbed] No mbed targets were detected on your system.")
except KeyboardInterrupt:
- print "\n[CTRL+c] exit"
+ print("\n[CTRL+c] exit")
except Exception as exc:
import traceback
traceback.print_exc(file=sys.stdout)
- print "[ERROR] %s" % str(exc)
+ print("[ERROR] %s" % str(exc))
sys.exit(1)
def get_interface_version(mount_point):
@@ -112,15 +113,14 @@
"""
if get_module_avail('mbed_lstools'):
try :
- mbeds = mbed_lstools.create()
- details_txt = mbeds.get_details_txt(mount_point)
+ mbedls = mbed_lstools.create()
+ mbeds = mbedls.list_mbeds(unique_names=True, read_details_txt=True)
- if 'Interface Version' in details_txt:
- return details_txt['Interface Version']
+ for mbed in mbeds:
+ if mbed['mount_point'] == mount_point:
- elif 'Version' in details_txt:
- return details_txt['Version']
-
+ if 'daplink_version' in mbed:
+ return mbed['daplink_version']
except :
return 'unknown'
