@@ -200,50 +200,62 @@ def check_config():
200
200
output = subprocess .check_output (
201
201
[arduino_cli , "version" ], stderr = subprocess .DEVNULL ,
202
202
)
203
+ except subprocess .CalledProcessError as e :
204
+ print ('"' + " " .join (e .cmd ) + '" failed with code: {}!' .format (e .returncode ))
205
+ print (e .stdout )
206
+ quit (e .returncode )
207
+ else :
203
208
res = re .match (r".*Version:\s+(\d+\.\d+\.\d+).*" , output .decode ("utf-8" ))
204
-
205
209
if res :
206
210
arduino_cli_version = res .group (1 )
207
211
print ("Arduino CLI version used: " + arduino_cli_version )
208
212
else :
209
- raise subprocess .CalledProcessError (1 , "re" )
210
- except subprocess .CalledProcessError :
211
- print (
212
- "Unable to define Arduino CLI version, use default: "
213
- + arduino_cli_default_version
214
- )
213
+ print (
214
+ "Unable to define Arduino CLI version, use default: "
215
+ + arduino_cli_default_version
216
+ )
215
217
216
218
try :
217
219
output = subprocess .check_output (
218
220
[arduino_cli , "core" , "search" , "stm32" , "--additional-urls" , stm32_url ],
219
221
stderr = subprocess .DEVNULL ,
220
222
)
223
+ except subprocess .CalledProcessError as e :
224
+ print ('"' + " " .join (e .cmd ) + '" failed with code: {}!' .format (e .returncode ))
225
+ print (e .stdout )
226
+ quit (e .returncode )
227
+ else :
221
228
if arduino_platform not in output .decode ("utf-8" ):
222
- raise subprocess .CalledProcessError (1 , "re" )
229
+ print (arduino_platform + " is not installed!" )
230
+ quit (1 )
223
231
# Add core and library path to sketches_path_list
224
232
try :
225
233
output = subprocess .check_output (
226
234
[arduino_cli , "config" , "dump" , "--format" , "json" ],
227
235
stderr = subprocess .DEVNULL ,
228
236
).decode ("utf-8" )
237
+ except subprocess .CalledProcessError as e :
238
+ print (
239
+ '"' + " " .join (e .cmd ) + '" failed with code: {}!' .format (e .returncode )
240
+ )
241
+ print (e .stdout )
242
+ quit (e .returncode )
243
+ else :
229
244
cli_config = json .loads (output )
230
245
if cli_config is not None :
231
246
if cli_config ["directories" ]["data" ] is not None :
232
247
sketches_path_list .append (cli_config ["directories" ]["data" ])
233
248
else :
234
- raise subprocess .CalledProcessError (3 , "No data directory" )
249
+ print ("No data directory" )
250
+ quit (1 )
235
251
if cli_config ["directories" ]["user" ] is not None :
236
252
sketches_path_list .append (cli_config ["directories" ]["user" ])
237
253
else :
238
- raise subprocess .CalledProcessError (2 , "No user directory" )
254
+ print ("No user directory!" )
255
+ quit (1 )
239
256
else :
240
- raise subprocess .CalledProcessError (1 , "No fqbn" )
241
- except subprocess .CalledProcessError :
242
- print ("No arduino-cli config!" )
243
- quit ()
244
- except subprocess .CalledProcessError :
245
- print (arduino_platform + " is not installed!" )
246
- quit ()
257
+ print ("No arduino-cli config!" )
258
+ quit (1 )
247
259
248
260
249
261
def load_core_config ():
@@ -386,7 +398,7 @@ def manage_inos():
386
398
break
387
399
else :
388
400
print ("Sketch {} path does not exist!" .format (args .ino ))
389
- quit ()
401
+ quit (1 )
390
402
# Sketches listed in a file
391
403
elif args .file :
392
404
assert os .path .exists (args .file ), "Sketches list file does not exist"
@@ -417,7 +429,7 @@ def manage_inos():
417
429
sketch_list .append (sketch_default )
418
430
if len (sketch_list ) == 0 :
419
431
print ("No sketch to build for " + arduino_platform + "!" )
420
- quit ()
432
+ quit (1 )
421
433
422
434
423
435
# Find all .ino files and save directory
@@ -449,32 +461,41 @@ def find_board():
449
461
try :
450
462
output = subprocess .check_output (
451
463
[arduino_cli , "board" , "listall" , "--format" , "json" ],
452
- stderr = subprocess .DEVNULL ,
464
+ stderr = subprocess .STDOUT ,
453
465
).decode ("utf-8" )
466
+ except subprocess .CalledProcessError as e :
467
+ print ('"' + " " .join (e .cmd ) + '" failed with code: {}!' .format (e .returncode ))
468
+ print (e .stdout )
469
+ quit (e .returncode )
470
+ else :
454
471
boards_list = json .loads (output )
455
472
if boards_list is not None :
456
473
for board in boards_list ["boards" ]:
457
474
if arduino_platform in board ["FQBN" ]:
458
475
fqbn_list_tmp .append (board ["FQBN" ])
459
- if not len (fqbn_list_tmp ):
460
- raise subprocess .CalledProcessError (2 , "No fqbn" )
461
- else :
462
- raise subprocess .CalledProcessError (1 , "No fqbn" )
463
- except subprocess .CalledProcessError :
464
- print ("No fqbn found for " + arduino_platform + "!" )
465
- quit ()
476
+ if not len (fqbn_list_tmp ):
477
+ print ("No boards found for " + arduino_platform )
478
+ quit (1 )
466
479
467
480
# For STM32 core, pnum is requested
468
481
for fqbn in fqbn_list_tmp :
469
482
try :
470
483
output = subprocess .check_output (
471
484
[arduino_cli , "board" , "details" , "--format" , "json" , fqbn ],
472
- stderr = subprocess .DEVNULL ,
485
+ stderr = subprocess .STDOUT ,
473
486
).decode ("utf-8" )
487
+ except subprocess .CalledProcessError as e :
488
+ print (
489
+ '"' + " " .join (e .cmd ) + '" failed with code: {}!' .format (e .returncode )
490
+ )
491
+ print (e .stdout )
492
+ quit (e .returncode )
493
+ else :
474
494
board_detail = json .loads (output )
475
495
if board_detail is not None :
476
496
if "config_options" not in board_detail :
477
- raise subprocess .CalledProcessError (3 , "No config_options" )
497
+ print ("No config_options found for " + fqbn )
498
+ quit (1 )
478
499
for option in board_detail ["config_options" ]:
479
500
if option ["option" ] == "pnum" :
480
501
for value in option ["values" ]:
@@ -486,14 +507,12 @@ def find_board():
486
507
)
487
508
break
488
509
else :
489
- raise subprocess .CalledProcessError (1 , "No fqbn" )
490
- except subprocess .CalledProcessError as e :
491
- print ("No fqbn detail found for " + e .cmd + "!" )
510
+ print ('No detail found for:"' + fqbn + '"!' )
492
511
if board_found :
493
512
board_fqbn = collections .OrderedDict (sorted (board_found .items ()))
494
513
else :
495
514
print ("No board found for " + arduino_platform + "!" )
496
- quit ()
515
+ quit (1 )
497
516
498
517
499
518
# Check the status
0 commit comments