Skip to content

Commit efb7cfb

Browse files
theotherjimmy0xc0170
authored andcommitted
Format detect_targets.py
1 parent c7bc655 commit efb7cfb

File tree

1 file changed

+27
-25
lines changed

1 file changed

+27
-25
lines changed

tools/detect_targets.py

Lines changed: 27 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -14,18 +14,13 @@
1414
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1515
See the License for the specific language governing permissions and
1616
limitations under the License.
17-
18-
19-
TEST BUILD & RUN
2017
"""
2118
import sys
2219
import os
23-
import json
2420

2521
ROOT = os.path.abspath(os.path.join(os.path.dirname(__file__), ".."))
2622
sys.path.insert(0, ROOT)
2723

28-
2924
from tools.options import get_default_options_parser
3025

3126
# Check: Extra modules which are required by core test suite
@@ -37,54 +32,61 @@
3732
from tools.test_api import get_autodetected_MUTS_list
3833

3934

40-
if __name__ == '__main__':
35+
def main():
36+
"""Entry Point"""
4137
try:
4238
# Parse Options
4339
parser = get_default_options_parser()
4440

4541
parser.add_argument("-S", "--supported-toolchains",
46-
action="store_true",
47-
dest="supported_toolchains",
48-
default=False,
49-
help="Displays supported matrix of targets and toolchains")
42+
action="store_true",
43+
dest="supported_toolchains",
44+
default=False,
45+
help="Displays supported matrix of"
46+
" targets and toolchains")
5047

5148
parser.add_argument('-f', '--filter',
52-
dest='general_filter_regex',
53-
default=None,
54-
help='Filter targets')
49+
dest='general_filter_regex',
50+
default=None,
51+
help='Filter targets')
5552

5653
parser.add_argument("-v", "--verbose",
57-
action="store_true",
58-
dest="verbose",
59-
default=False,
60-
help="Verbose diagnostic output")
54+
action="store_true",
55+
dest="verbose",
56+
default=False,
57+
help="Verbose diagnostic output")
6158

6259
options = parser.parse_args()
6360

6461
# Only prints matrix of supported toolchains
6562
if options.supported_toolchains:
66-
print mcu_toolchain_matrix(platform_filter=options.general_filter_regex)
63+
print mcu_toolchain_matrix(
64+
platform_filter=options.general_filter_regex)
6765
exit(0)
6866

6967
# If auto_detect attribute is present, we assume other auto-detection
7068
# parameters like 'toolchains_filter' are also set.
71-
MUTs = get_autodetected_MUTS_list()
69+
muts = get_autodetected_MUTS_list()
7270

7371
count = 0
74-
for mut in MUTs.values():
72+
for mut in muts.values():
7573
print ""
76-
print "[mbed] Detected %s, port %s, mounted %s" % (mut['mcu'], mut['port'], mut['disk'])
74+
print "[mbed] Detected %s, port %s, mounted %s" % \
75+
(mut['mcu'], mut['port'], mut['disk'])
7776
print "[mbed] Supported toolchains for %s" % mut['mcu']
7877
print mcu_toolchain_matrix(platform_filter=r'^'+mut['mcu']+'$')
7978
count += 1
80-
79+
8180
if count == 0:
8281
print "[mbed] No mbed targets where detected on your system."
8382

84-
except KeyboardInterrupt, e:
83+
except KeyboardInterrupt:
8584
print "\n[CTRL+c] exit"
86-
except Exception,e:
85+
except Exception as exc:
8786
import traceback
8887
traceback.print_exc(file=sys.stdout)
89-
print "[ERROR] %s" % str(e)
88+
print "[ERROR] %s" % str(exc)
9089
sys.exit(1)
90+
91+
if __name__ == '__main__':
92+
main()

0 commit comments

Comments
 (0)