Skip to content

Commit fa2c172

Browse files
committed
retry up to 3 times for run_or_die()
1 parent 3907bae commit fa2c172

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

build_platform.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -179,9 +179,14 @@ def install_platform(platform):
179179

180180
def run_or_die(cmd, error):
181181
print(cmd)
182-
if os.system(cmd) != 0:
183-
ColorPrint.print_fail(error)
184-
exit(-1)
182+
attempt = 0
183+
while attempt < 3:
184+
if os.system(cmd) == 0:
185+
return
186+
attempt += 1
187+
print('attempt {} failed, {} retry left'.format(attempt, 3-attempt))
188+
ColorPrint.print_fail(error)
189+
exit(-1)
185190

186191
################################ Install Arduino IDE
187192
print()

0 commit comments

Comments
 (0)