52 lines
1.1 KiB
Python
52 lines
1.1 KiB
Python
"""
|
|
TBD
|
|
"""
|
|
|
|
__author__ = "Lukas Mahler"
|
|
__version__ = "0.0.0"
|
|
__date__ = "25.09.2021"
|
|
__email__ = "m@hler.eu"
|
|
__status__ = "Development"
|
|
|
|
|
|
# Default
|
|
import threading
|
|
import logging
|
|
from datetime import date
|
|
|
|
|
|
class MyTimer(threading.Timer):
|
|
def run(self):
|
|
print(self.__dict__)
|
|
print(f"{self._name} Run once")
|
|
while not self.finished.wait(self.interval):
|
|
print(f"{self._name} Run x")
|
|
self.function(*self.args, **self.kwargs)
|
|
print(f"{self._name} Ran x")
|
|
print(f"{self._name} Run end")
|
|
|
|
|
|
def maketimer(cooldown, func):
|
|
timer = MyTimer(cooldown, func)
|
|
timer.daemon = True
|
|
return timer
|
|
|
|
|
|
def setupLogger():
|
|
"""
|
|
|
|
"""
|
|
log = logging.getLogger()
|
|
now = date.today().strftime("%Y-%m-%d")
|
|
handler = logging.FileHandler(f"myTS3_{now}_{__version__}.log", encoding="utf-8")
|
|
logformat = logging.Formatter("%(asctime)s %(levelname)7s %(message)s", "%d-%m-%Y %H:%M:%S")
|
|
handler.setFormatter(logformat)
|
|
log.addHandler(handler)
|
|
log.setLevel(logging.DEBUG)
|
|
|
|
return log
|
|
|
|
|
|
if __name__ == "__main__":
|
|
exit()
|