import schedule
import time
import logging

logging.basicConfig(filename='logs/scheduler.log', level=logging.INFO)
schedule_logger = logging.getLogger('schedule')


def ping():
    print("I'm working...")


def status():
    print("I'm working...")


def batch():
    print("I'm working...")


def send_mail():
    print("I'm working...")


def evaluate(cmd):
    eval(cmd, {'repeat': schedule, 'ping': ping, 'status': status, 'batch': batch, 'send_mail': send_mail})


config = ['repeat.every(10).to(15).seconds.do(ping)', 'repeat.every().hour.do(status)', 'repeat.every().day.at("05:30").do(batch, "GAPS.bat")']
# repeat.every().monday.at("8:30").do(send_mail)
# repeat.every().wednesday.at("13:15").do(send_mail)
for c in config:
    evaluate(c)


while True:
    schedule.run_pending()
    n = schedule.idle_seconds()
    print("Waiting " + str(n) + " seconds...")
    time.sleep(n)