fix: Add is_worker_allowed_to_run function definition

Function was referenced but not defined - added implementation
This commit is contained in:
mindesbunister
2025-12-04 15:16:18 +01:00
parent 0babd1ea1a
commit f2f2992a98

View File

@@ -64,6 +64,29 @@ def send_telegram_message(message: str):
except Exception as e:
print(f"⚠️ Error sending Telegram notification: {e}")
def is_worker_allowed_to_run(worker_name: str) -> bool:
"""Check if worker is allowed to run based on time restrictions"""
worker = WORKERS[worker_name]
# If no time restriction, always allowed
if not worker.get('time_restricted', False):
return True
# Check current hour (local time)
current_hour = datetime.now().hour
start_hour = worker['allowed_start_hour']
end_hour = worker['allowed_end_hour']
# Handle time range that crosses midnight (e.g., 19:00 - 06:00)
if start_hour > end_hour:
# Allowed if current hour >= start OR current hour < end
allowed = current_hour >= start_hour or current_hour < end_hour
else:
# Normal range (e.g., 8:00 - 17:00)
allowed = start_hour <= current_hour < end_hour
return allowed
def signal_handler(sig, frame):
"""Handle termination signals"""
message = (