File tree 1 file changed +15
-3
lines changed
1 file changed +15
-3
lines changed Original file line number Diff line number Diff line change 2
2
import glob
3
3
import time
4
4
import os
5
+ import re
5
6
import shutil
6
7
import subprocess
7
8
import collections
@@ -166,6 +167,14 @@ def run_or_die(cmd, error):
166
167
167
168
print ()
168
169
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
+
169
178
################################ Install dependencies
170
179
our_name = None
171
180
try :
@@ -180,9 +189,12 @@ def run_or_die(cmd, error):
180
189
deps = line .replace ("depends=" , "" ).split ("," )
181
190
for dep in deps :
182
191
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 )
186
198
except OSError :
187
199
print ("No library dep or properties found!" )
188
200
pass # no library properties
You can’t perform that action at this time.
0 commit comments