@@ -193,7 +193,7 @@ def check_config():
193
193
arduino_cli = arduino_cli_path / "arduino-cli.exe"
194
194
else :
195
195
arduino_cli = arduino_cli_path / "arduino-cli"
196
-
196
+ # Check arduino-cli version
197
197
try :
198
198
output = subprocess .check_output (
199
199
[arduino_cli , "version" ],
@@ -217,15 +217,46 @@ def check_config():
217
217
if args .url :
218
218
stm32_url = args .url
219
219
220
+ # Check if url is already part of the arduino-cli config
221
+ try :
222
+ output = subprocess .check_output (
223
+ [
224
+ arduino_cli ,
225
+ "config" ,
226
+ "dump" ,
227
+ ],
228
+ stderr = subprocess .STDOUT ,
229
+ )
230
+ except subprocess .CalledProcessError as e :
231
+ print (f"'{ ' ' .join (e .cmd )} ' failed with code: { e .returncode } !" )
232
+ print (e .stdout .decode ("utf-8" ))
233
+ quit (e .returncode )
234
+ else :
235
+ if stm32_url not in output .decode ("utf-8" ):
236
+ # Add it to the config
237
+ try :
238
+ output = subprocess .check_output (
239
+ [
240
+ arduino_cli ,
241
+ "config" ,
242
+ "add" ,
243
+ "board_manager.additional_urls" ,
244
+ stm32_url ,
245
+ ],
246
+ stderr = subprocess .STDOUT ,
247
+ )
248
+ except subprocess .CalledProcessError as e :
249
+ print (f"'{ ' ' .join (e .cmd )} ' failed with code: { e .returncode } !" )
250
+ print (e .stdout .decode ("utf-8" ))
251
+ quit (e .returncode )
252
+ # Check if requested platform is installed
220
253
try :
221
254
output = subprocess .check_output (
222
255
[
223
256
arduino_cli ,
224
257
"core" ,
225
258
"search" ,
226
259
"stm32" ,
227
- "--additional-urls" ,
228
- stm32_url ,
229
260
],
230
261
stderr = subprocess .STDOUT ,
231
262
)
@@ -492,8 +523,6 @@ def find_board():
492
523
arduino_cli ,
493
524
"board" ,
494
525
"details" ,
495
- "--additional-urls" ,
496
- stm32_url ,
497
526
"--format" ,
498
527
"json" ,
499
528
"-b" ,
0 commit comments