New arguments to handle cache expiration

This commit is contained in:
nemunaire 2022-12-30 19:54:21 +01:00
commit f79022b7a3
5 changed files with 65 additions and 25 deletions

View file

@ -6,7 +6,10 @@ from PIL import Image, ImageDraw, ImageFont
class Config:
def __init__(self, cals_file_list=".cals"):
def __init__(self, cache_timeout, max_cache_timeout, cals_file_list=".cals"):
self.cache_timeout = cache_timeout
self.max_cache_timeout = max_cache_timeout
if os.path.exists('/usr/share/fonts/source-pro/'):
self.fnt_R_path = "/usr/share/fonts/source-pro/SourceSansPro-Regular.otf"
self.fnt_RI_path = "/usr/share/fonts/source-pro/SourceSansPro-It.otf"
@ -140,14 +143,16 @@ class AlertsModule:
align = 7
for alert in self.alerts:
args = []
args_module = []
args_func = []
if isinstance(alert, dict) and "module" in alert:
args = alert["args"] if "args" in alert else []
args_module = alert["args_module"] if "args_module" in alert else []
args_func = alert["args_func"] if "args_func" in alert else []
alert = alert["module"]
if isinstance(alert, type):
try:
for alert in alert(*args).gen_alerts():
for alert in alert(*args_module).gen_alerts(*args_func):
align = self.draw_alert(alert, width, image, draw, fnt_R, fnt_B, align, font_size)
except BaseException as e:
logging.exception(e)