import schedule
import time
import logging
from config.Aufgaben import run_tasks


class Tasks:
    repeat: schedule.Scheduler

    def __init__(self, s: schedule.Scheduler):
        self.repeat = s

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

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

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

    def call(self, command):
        print("I'm working...")

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


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


def main():
    tasks = Tasks(schedule.Scheduler())
    run_tasks(tasks)

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


if __name__ == '__main__':
    main()
