scheduler.py 927 B

12345678910111213141516171819202122232425262728293031323334353637383940
  1. import schedule
  2. import time
  3. import logging
  4. logging.basicConfig(filename='logs/scheduler.log', level=logging.INFO)
  5. schedule_logger = logging.getLogger('schedule')
  6. def ping():
  7. print("I'm working...")
  8. def status():
  9. print("I'm working...")
  10. def batch():
  11. print("I'm working...")
  12. def send_mail():
  13. print("I'm working...")
  14. def evaluate(cmd):
  15. eval(cmd, {'repeat': schedule, 'ping': ping, 'status': status, 'batch': batch, 'send_mail': send_mail})
  16. config = ['repeat.every(10).to(15).seconds.do(ping)', 'repeat.every().hour.do(status)', 'repeat.every().day.at("05:30").do(batch, "GAPS.bat")']
  17. # repeat.every().monday.at("8:30").do(send_mail)
  18. # repeat.every().wednesday.at("13:15").do(send_mail)
  19. for c in config:
  20. evaluate(c)
  21. while True:
  22. schedule.run_pending()
  23. n = schedule.idle_seconds()
  24. print("Waiting " + str(n) + " seconds...")
  25. time.sleep(n)