forked from arjun-shanmugam/deep-net
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrun_scheduled_tasks.py
31 lines (28 loc) · 933 Bytes
/
run_scheduled_tasks.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
import schedule
import time
from utils.send_email import send_email
from utils.run_git_commands import git_push_updated_db
from deep_net.database import Database
import argparse
def daily_tasks(db):
#Fetch updated data
db.update_games_table()
db.update_boxscores_table()
send_email(["1"]) #TODO: Make preds, and email them
git_push_updated_db()
print("Pushed to remote")
def run(db):
# time.sleep(30) #sleep 30 secs (testing purposes)
# schedule.every(2).minutes.do(daily_tasks, db)
schedule.every().day.at("09:00").do(daily_tasks, db) #9 AM
while True:
schedule.run_pending()
time.sleep(1)
if __name__ == "__main__":
parser = argparse.ArgumentParser()
parser.add_argument('--run_tasks_now', dest='run_tasks_now', action='store_true')
args = parser.parse_args()
db = Database("data/nbastats.db")
if args.run_tasks_now:
daily_tasks(db)
run(db)