Better logs and better timings

This commit is contained in:
Remy Moll 2021-01-29 22:04:25 +01:00
parent 39ae1ec038
commit 5613b1043c
3 changed files with 16 additions and 22 deletions

View File

@ -10,10 +10,19 @@ import persistence.main
# various
import logging
from threading import Thread
import os
if os.name == "nt":
logging.basicConfig(
format='%(asctime)s - %(name)s - %(levelname)s - %(message)s', level=logging.INFO
)
else:
logging.basicConfig(
format='%(asctime)s - %(name)s - %(levelname)s - %(message)s',
level=logging.INFO,
filename='persistence/complete.log',
)
logging.basicConfig(
format='%(asctime)s - %(name)s - %(levelname)s - %(message)s', level=logging.INFO
)
class Launcher():
"""Launches all other submodules"""

13
t.py
View File

@ -1,13 +0,0 @@
import bot2.main
import persistence.main
import logging
logging.basicConfig(
format='%(asctime)s - %(name)s - %(levelname)s - %(message)s',
level=logging.INFO,
#filename='persistence/complete.log',
)
logger = logging.getLogger(__name__)
prst = persistence.main.PersistentDict("persistence/prst.json")
test = bot2.main.ChatBot("Test", ".1", "HW", prst, logger)

View File

@ -36,7 +36,6 @@ class ClockWrapper(Wrapper):
def START(self): # I prefer the name tick_tack
"""Runs the showing of the clock-face periodically: update every minute"""
def perform_loop():
logger.warning("NEW TIME")
t = int(datetime.datetime.now().strftime("%H%M"))
if t % 5 == 0:
@ -45,7 +44,6 @@ class ClockWrapper(Wrapper):
if weather != self.weather_raw and len(weather) != 0:
td = weather[1]
low = td["temps"][0]
high = td["temps"][1]
self.weather["weather"] = td["short"]
@ -62,16 +60,16 @@ class ClockWrapper(Wrapper):
else:
next = "weather"
self.weather["show"] = next
self.prev_time = datetime.datetime.now().strftime("%H%M")
self.own.set_face(self.weather)
perform_loop()
while datetime.datetime.now().strftime("%H%M%S")[-2:] != "00":
pass
RepeatedTimer(60, perform_loop)
class BotWrapper(Wrapper):
"""Wrapper for the BOT-functionality"""
def __init__(self, own_module, *other_modules):