forked from Netflix/dynomite
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrun_loop.py
executable file
·30 lines (26 loc) · 969 Bytes
/
run_loop.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
#!/usr/bin/env python3
import subprocess, time
def run_command(cmd):
"""Execute a shell command and return the output
:param command: the command to be run and all of the arguments
:returns: success_boolean, command_string, stdout, stderr
"""
proc = subprocess.Popen(cmd, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
for line in iter(proc.stdout.readline, b''):
print(">>> " + line.rstrip())
(stdout, stderr) = proc.communicate()
return proc.returncode == 0, proc
def main():
cmd = "bash travis.sh -n"
for i in range(0, 50):
print("Running loop {}".format(i+1))
success, proc = run_command(cmd)
if not success:
for line in iter(proc.stderr.readline, b''):
print(("--- " + line.rstrip()))
break
else:
print("...........................Success\n")
time.sleep(30)
if __name__ == "__main__":
main()