1
Fork 0

Allow running script with interval

This commit is contained in:
Jake Howard 2020-01-19 19:51:44 +00:00
parent 38856fa223
commit 7b0a1d0f16
Signed by: jake
GPG key ID: 57AFB45680EDD477

View file

@ -1,13 +1,31 @@
#!/usr/bin/env python3 #!/usr/bin/env python3
import argparse
import time
from .tasks import ALL_TASKS from .tasks import ALL_TASKS
def main(): def get_args():
parser = argparse.ArgumentParser()
parser.add_argument("--interval", type=int, default=0)
return parser.parse_args()
def run_tasks():
for task in ALL_TASKS: for task in ALL_TASKS:
print("Executing", task.__name__) print("Executing", task.__name__)
task() task()
def main():
args = get_args()
run_tasks()
if args.interval:
while True:
run_tasks()
time.sleep(args.interval)
if __name__ == "__main__": if __name__ == "__main__":
main() main()