| 1 |
#!/bin/python |
| 2 |
|
| 3 |
import time |
| 4 |
import sys |
| 5 |
|
| 6 |
sleep_seconds = int(sys.argv[1]) |
| 7 |
num_stores = int(sys.argv[2]) |
| 8 |
file_input = sys.argv[3] |
| 9 |
|
| 10 |
try: |
| 11 |
input = open(file_input, "r") |
| 12 |
except Exception as err: |
| 13 |
print(err, file=sys.stderr) |
| 14 |
sys.exit(1) |
| 15 |
|
| 16 |
InterestingStores = 0 |
| 17 |
for line in input: |
| 18 |
if "store" in line: |
| 19 |
InterestingStores += 1 |
| 20 |
|
| 21 |
print("Interesting stores ", InterestingStores, " sleeping ", sleep_seconds) |
| 22 |
time.sleep(sleep_seconds) |
| 23 |
|
| 24 |
|
| 25 |
if InterestingStores > num_stores: |
| 26 |
sys.exit(0) # interesting! |
| 27 |
|
| 28 |
sys.exit(1) # IR isn't interesting |