appmethods.py 942 Bytes
Newer Older
1 2
# app imports
from parscript import load_data
3
from getconnectedscript import load_gc_data
4 5 6 7
import redisactions as f

# python imports
import json
8
import datetime
9
import time
10

11 12
# other imports
import redis
13
import schedule
14

15 16

# attempts to update both dbs and logs the result
17 18 19
def update_both_dbs():
    livesuccess = f.live_db_fill(json.dumps(load_data(), ensure_ascii=False))
    gcsuccess = f.gc_db_fill(json.dumps(load_gc_data(), ensure_ascii=False))
20 21 22 23 24
    successLog = str(datetime.datetime.now()) \
        + "\n\nAttempted to update cache." \
        + "\n25Live: " + str(livesuccess) \
        + "\nGC: " + str(gcsuccess)

25
    f.append_to_update_log(successLog)
26
    return successLog
27 28


29
# setting up cacheing
30 31
# this must be done after the update_both_dbs def
schedule.every().day.at("02:00").do(update_both_dbs)
32 33


34
def run_schedule_loop():
35 36 37 38
    runScheduler = True
    while runScheduler:
        schedule.run_pending()
        time.sleep(1800)