forked from erikrose/blessings
-
Notifications
You must be signed in to change notification settings - Fork 0
/
run_codecov.py
47 lines (36 loc) · 948 Bytes
/
run_codecov.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
"""
Workaround for https://github.com/codecov/codecov-python/issues/158
"""
# std imports
import sys
import time
# local
import codecov
RETRIES = 5
TIMEOUT = 2
def main():
"""
Run codecov up to RETRIES times
On the final attempt, let it exit normally
"""
# Make a copy of argv and make sure --required is in it
args = sys.argv[1:]
if '--required' not in args:
args.append('--required')
for num in range(1, RETRIES + 1):
print('Running codecov attempt %d: ' % num)
# On the last, let codecov handle the exit
if num == RETRIES:
codecov.main()
try:
codecov.main(*args)
except SystemExit as err:
# If there's no exit code, it was successful
if err.code:
time.sleep(TIMEOUT)
else:
sys.exit(err.code)
else:
break
if __name__ == '__main__':
main()