File tree Expand file tree Collapse file tree 1 file changed +15
-3
lines changed Expand file tree Collapse file tree 1 file changed +15
-3
lines changed Original file line number Diff line number Diff line change 22import glob
33import time
44import os
5+ import re
56import shutil
67import subprocess
78import collections
@@ -166,6 +167,14 @@ def run_or_die(cmd, error):
166167
167168print ()
168169
170+ def is_library_installed (lib_name ):
171+ try :
172+ installed_libs = subprocess .check_output (["arduino-cli" , "lib" , "list" ]).decode ("utf-8" )
173+ return not all (not item for item in [re .match ('^' + dep + '\\ s*\\ d+\\ .' , line ) for line in installed_libs .split ('\n ' )])
174+ except subprocess .CalledProcessError as e :
175+ print ("Error checking installed libraries:" , e )
176+ return False
177+
169178################################ Install dependencies
170179our_name = None
171180try :
@@ -180,9 +189,12 @@ def run_or_die(cmd, error):
180189 deps = line .replace ("depends=" , "" ).split ("," )
181190 for dep in deps :
182191 dep = dep .strip ()
183- print ("Installing " + dep )
184- run_or_die ('arduino-cli lib install "' + dep + '" > /dev/null' ,
185- "FAILED to install dependency " + dep )
192+ if not is_library_installed (dep ):
193+ print ("Installing " + dep )
194+ run_or_die ('arduino-cli lib install "' + dep + '" > /dev/null' ,
195+ "FAILED to install dependency " + dep )
196+ else :
197+ print ("Skipping already installed lib: " + dep )
186198except OSError :
187199 print ("No library dep or properties found!" )
188200 pass # no library properties
You can’t perform that action at this time.
0 commit comments