Skip to content

Commit 74255d5

Browse files
committed
fix(arduino-cli): support 1.x version
Some data format have changed. Signed-off-by: Frederic Pillon <[email protected]>
1 parent e194ab8 commit 74255d5

File tree

1 file changed

+25
-10
lines changed

1 file changed

+25
-10
lines changed

CI/build/arduino-cli.py

+25-10
Original file line numberDiff line numberDiff line change
@@ -297,16 +297,27 @@ def check_config():
297297
else:
298298
cli_config = json.loads(output)
299299
if cli_config is not None:
300-
if cli_config["directories"]["data"] is not None:
301-
sketches_path_list.append(Path(cli_config["directories"]["data"]))
302-
else:
303-
print("No data directory")
304-
quit(1)
305-
if cli_config["directories"]["user"] is not None:
306-
sketches_path_list.append(Path(cli_config["directories"]["user"]))
300+
# Since arduino-cli 1.x new level "config"
301+
if "config" in cli_config.keys():
302+
cli_config = cli_config["config"]
303+
# Since arduino-cli 1.x config init does not create full config
304+
if "directories" in cli_config.keys():
305+
if "data" in cli_config["directories"].key():
306+
if cli_config["directories"]["data"] is not None:
307+
sketches_path_list.append(
308+
Path(cli_config["directories"]["data"])
309+
)
310+
else:
311+
print("No data directory")
312+
if "user" in cli_config["directories"].key():
313+
if cli_config["directories"]["user"] is not None:
314+
sketches_path_list.append(
315+
Path(cli_config["directories"]["user"])
316+
)
317+
else:
318+
print("No user directory!")
307319
else:
308-
print("No user directory!")
309-
quit(1)
320+
print("No directories in config!")
310321
# Fill search_path_list to avoid search on the same path
311322
sorted_spl = sorted(set(sketches_path_list))
312323
search_path_list = []
@@ -526,7 +537,11 @@ def find_board():
526537
print(e.stdout.decode("utf-8"))
527538
quit(e.returncode)
528539
else:
529-
fqbn_list_tmp = [board["fqbn"] for board in json.loads(output)]
540+
boards = json.loads(output)
541+
# Since arduino-cli 1.x new level "boards" and is a dict
542+
if type(boards) is dict:
543+
boards = boards["boards"]
544+
fqbn_list_tmp = [board["fqbn"] for board in boards]
530545
if not len(fqbn_list_tmp):
531546
print(f"No boards found for {arduino_platform}")
532547
quit(1)

0 commit comments

Comments
 (0)