@@ -224,38 +224,47 @@ def check_config():
224224 if args .url :
225225 stm32_url = args .url
226226
227- # Check if url is already part of the arduino-cli config
227+ # Ensure a configuration exists
228228 try :
229+ print ("Check/update arduino-cli configuration" )
230+ # Try to create configuration file
229231 output = subprocess .check_output (
230- [
231- arduino_cli ,
232- "config" ,
233- "dump" ,
234- ],
232+ [arduino_cli , "config" , "init" , "--additional-urls" , stm32_url ],
235233 stderr = subprocess .STDOUT ,
236- )
237- except subprocess .CalledProcessError as e :
238- print (f"'{ ' ' .join (e .cmd )} ' failed with code: { e .returncode } !" )
239- print (e .stdout .decode ("utf-8" ))
240- quit (e .returncode )
241- else :
242- if stm32_url not in output .decode ("utf-8" ):
243- # Add it to the config
244- try :
245- output = subprocess .check_output (
246- [
247- arduino_cli ,
248- "config" ,
249- "add" ,
250- "board_manager.additional_urls" ,
251- stm32_url ,
252- ],
253- stderr = subprocess .STDOUT ,
254- )
255- except subprocess .CalledProcessError as e :
256- print (f"'{ ' ' .join (e .cmd )} ' failed with code: { e .returncode } !" )
257- print (e .stdout .decode ("utf-8" ))
258- quit (e .returncode )
234+ ).decode ("utf-8" )
235+ except subprocess .CalledProcessError :
236+ try :
237+ output = subprocess .check_output (
238+ [
239+ arduino_cli ,
240+ "config" ,
241+ "dump" ,
242+ ],
243+ stderr = subprocess .STDOUT ,
244+ )
245+ except subprocess .CalledProcessError as e :
246+ print (f"'{ ' ' .join (e .cmd )} ' failed with code: { e .returncode } !" )
247+ print (e .stdout .decode ("utf-8" ))
248+ quit (e .returncode )
249+ else :
250+ # Check if url is already part of the arduino-cli config
251+ if stm32_url not in output .decode ("utf-8" ):
252+ # Add it to the config
253+ try :
254+ output = subprocess .check_output (
255+ [
256+ arduino_cli ,
257+ "config" ,
258+ "add" ,
259+ "board_manager.additional_urls" ,
260+ stm32_url ,
261+ ],
262+ stderr = subprocess .STDOUT ,
263+ )
264+ except subprocess .CalledProcessError as e :
265+ print (f"'{ ' ' .join (e .cmd )} ' failed with code: { e .returncode } !" )
266+ print (e .stdout .decode ("utf-8" ))
267+ quit (e .returncode )
259268 # Check if requested platform is installed
260269 try :
261270 output = subprocess .check_output (
0 commit comments