blob: 4aea815e6375d33cbdf61de03b9a1666e29c843b (
plain)
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
|
#!/usr/bin/python
"""Run a command until it succeeds.
Lars Wirzenius <liw@liw.fi>
"""
import subprocess
import sys
import time
def do_until(argv):
while True:
p = subprocess.Popen(argv)
p.communicate()
if p.returncode == 0:
break
sys.stderr.write("do-until: command failed, "
"trying again in 1 second\n")
time.sleep(1)
def main():
argv = sys.argv[1:]
if argv:
do_until(argv)
if __name__ == "__main__":
main()
|