expephalon/core/modules/cron.py

18 lines
568 B
Python
Raw Normal View History

import importlib
from django.conf import settings
cronfunctions = {}
crondefinitions = []
for module in ["core"] + settings.EXPEPHALON_MODULES:
try:
moc = importlib.import_module(f"{module}.cron")
for name, fun in moc.CRONFUNCTIONS.items():
if name in cronfunctions.keys():
raise ValueError(f"Error in {module}: Cron function with name {name} already registered!")
cronfunctions[name] = fun
crondefinitions += moc.CRONDEFINITIONS
except (AttributeError, ModuleNotFoundError):
continue