|
|
@ -24,6 +24,9 @@ class Failed(Exception):
|
|
|
|
class NotScheduled(Exception):
|
|
|
|
class NotScheduled(Exception):
|
|
|
|
pass
|
|
|
|
pass
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class NotScheduledRange(NotScheduled):
|
|
|
|
|
|
|
|
pass
|
|
|
|
|
|
|
|
|
|
|
|
class ImageData:
|
|
|
|
class ImageData:
|
|
|
|
def __init__(self, attribute, location, prefix="", is_poster=True, is_url=True):
|
|
|
|
def __init__(self, attribute, location, prefix="", is_poster=True, is_url=True):
|
|
|
|
self.attribute = attribute
|
|
|
|
self.attribute = attribute
|
|
|
@ -375,12 +378,14 @@ def check_day(_m, _d):
|
|
|
|
|
|
|
|
|
|
|
|
def schedule_check(attribute, data, current_time, run_hour):
|
|
|
|
def schedule_check(attribute, data, current_time, run_hour):
|
|
|
|
skip_collection = True
|
|
|
|
skip_collection = True
|
|
|
|
|
|
|
|
range_collection = False
|
|
|
|
schedule_list = get_list(data)
|
|
|
|
schedule_list = get_list(data)
|
|
|
|
next_month = current_time.replace(day=28) + timedelta(days=4)
|
|
|
|
next_month = current_time.replace(day=28) + timedelta(days=4)
|
|
|
|
last_day = next_month - timedelta(days=next_month.day)
|
|
|
|
last_day = next_month - timedelta(days=next_month.day)
|
|
|
|
schedule_str = ""
|
|
|
|
schedule_str = ""
|
|
|
|
for schedule in schedule_list:
|
|
|
|
for schedule in schedule_list:
|
|
|
|
run_time = str(schedule).lower()
|
|
|
|
run_time = str(schedule).lower()
|
|
|
|
|
|
|
|
display = f"{attribute} attribute {schedule} invalid"
|
|
|
|
if run_time.startswith(("day", "daily")):
|
|
|
|
if run_time.startswith(("day", "daily")):
|
|
|
|
skip_collection = False
|
|
|
|
skip_collection = False
|
|
|
|
elif run_time == "never":
|
|
|
|
elif run_time == "never":
|
|
|
@ -400,10 +405,10 @@ def schedule_check(attribute, data, current_time, run_hour):
|
|
|
|
else:
|
|
|
|
else:
|
|
|
|
raise ValueError
|
|
|
|
raise ValueError
|
|
|
|
except ValueError:
|
|
|
|
except ValueError:
|
|
|
|
logger.error(f"Schedule Error: hourly {attribute} attribute {schedule} invalid must be an integer between 0 and 23")
|
|
|
|
logger.error(f"Schedule Error: hourly {display} must be an integer between 0 and 23")
|
|
|
|
elif run_time.startswith("week"):
|
|
|
|
elif run_time.startswith("week"):
|
|
|
|
if param.lower() not in days_alias:
|
|
|
|
if param.lower() not in days_alias:
|
|
|
|
logger.error(f"Schedule Error: weekly {attribute} attribute {schedule} invalid must be a day of the week i.e. weekly(Monday)")
|
|
|
|
logger.error(f"Schedule Error: weekly {display} must be a day of the week i.e. weekly(Monday)")
|
|
|
|
continue
|
|
|
|
continue
|
|
|
|
weekday = days_alias[param.lower()]
|
|
|
|
weekday = days_alias[param.lower()]
|
|
|
|
schedule_str += f"\nScheduled weekly on {pretty_days[weekday]}"
|
|
|
|
schedule_str += f"\nScheduled weekly on {pretty_days[weekday]}"
|
|
|
@ -419,7 +424,7 @@ def schedule_check(attribute, data, current_time, run_hour):
|
|
|
|
else:
|
|
|
|
else:
|
|
|
|
raise ValueError
|
|
|
|
raise ValueError
|
|
|
|
except ValueError:
|
|
|
|
except ValueError:
|
|
|
|
logger.error(f"Schedule Error: monthly {attribute} attribute {schedule} invalid must be an integer between 1 and 31")
|
|
|
|
logger.error(f"Schedule Error: monthly {display} must be an integer between 1 and 31")
|
|
|
|
elif run_time.startswith("year"):
|
|
|
|
elif run_time.startswith("year"):
|
|
|
|
try:
|
|
|
|
try:
|
|
|
|
if "/" in param:
|
|
|
|
if "/" in param:
|
|
|
@ -433,12 +438,11 @@ def schedule_check(attribute, data, current_time, run_hour):
|
|
|
|
else:
|
|
|
|
else:
|
|
|
|
raise ValueError
|
|
|
|
raise ValueError
|
|
|
|
except ValueError:
|
|
|
|
except ValueError:
|
|
|
|
logger.error(
|
|
|
|
logger.error(f"Schedule Error: yearly {display} must be in the MM/DD format i.e. yearly(11/22)")
|
|
|
|
f"Schedule Error: yearly {attribute} attribute {schedule} invalid must be in the MM/DD format i.e. yearly(11/22)")
|
|
|
|
|
|
|
|
elif run_time.startswith("range"):
|
|
|
|
elif run_time.startswith("range"):
|
|
|
|
match = re.match("^(1[0-2]|0?[1-9])/(3[01]|[12][0-9]|0?[1-9])-(1[0-2]|0?[1-9])/(3[01]|[12][0-9]|0?[1-9])$", param)
|
|
|
|
match = re.match("^(1[0-2]|0?[1-9])/(3[01]|[12][0-9]|0?[1-9])-(1[0-2]|0?[1-9])/(3[01]|[12][0-9]|0?[1-9])$", param)
|
|
|
|
if not match:
|
|
|
|
if not match:
|
|
|
|
logger.error(f"Schedule Error: range {attribute} attribute {schedule} invalid must be in the MM/DD-MM/DD format i.e. range(12/01-12/25)")
|
|
|
|
logger.error(f"Schedule Error: range {display} must be in the MM/DD-MM/DD format i.e. range(12/01-12/25)")
|
|
|
|
continue
|
|
|
|
continue
|
|
|
|
month_start, day_start = check_day(int(match.group(1)), int(match.group(2)))
|
|
|
|
month_start, day_start = check_day(int(match.group(1)), int(match.group(2)))
|
|
|
|
month_end, day_end = check_day(int(match.group(3)), int(match.group(4)))
|
|
|
|
month_end, day_end = check_day(int(match.group(3)), int(match.group(4)))
|
|
|
@ -446,12 +450,15 @@ def schedule_check(attribute, data, current_time, run_hour):
|
|
|
|
check = datetime.strptime(f"{month_check}/{day_check}", "%m/%d")
|
|
|
|
check = datetime.strptime(f"{month_check}/{day_check}", "%m/%d")
|
|
|
|
start = datetime.strptime(f"{month_start}/{day_start}", "%m/%d")
|
|
|
|
start = datetime.strptime(f"{month_start}/{day_start}", "%m/%d")
|
|
|
|
end = datetime.strptime(f"{month_end}/{day_end}", "%m/%d")
|
|
|
|
end = datetime.strptime(f"{month_end}/{day_end}", "%m/%d")
|
|
|
|
|
|
|
|
range_collection = True
|
|
|
|
schedule_str += f"\nScheduled between {pretty_months[month_start]} {make_ordinal(day_start)} and {pretty_months[month_end]} {make_ordinal(day_end)}"
|
|
|
|
schedule_str += f"\nScheduled between {pretty_months[month_start]} {make_ordinal(day_start)} and {pretty_months[month_end]} {make_ordinal(day_end)}"
|
|
|
|
if start <= check <= end if start < end else (check <= end or check >= start):
|
|
|
|
if start <= check <= end if start < end else (check <= end or check >= start):
|
|
|
|
skip_collection = False
|
|
|
|
skip_collection = False
|
|
|
|
else:
|
|
|
|
else:
|
|
|
|
logger.error(f"Schedule Error: {attribute} attribute {schedule} invalid")
|
|
|
|
logger.error(f"Schedule Error: {display}")
|
|
|
|
if len(schedule_str) == 0:
|
|
|
|
if len(schedule_str) == 0:
|
|
|
|
skip_collection = False
|
|
|
|
skip_collection = False
|
|
|
|
if skip_collection:
|
|
|
|
if skip_collection and range_collection:
|
|
|
|
|
|
|
|
raise NotScheduledRange(schedule_str)
|
|
|
|
|
|
|
|
elif skip_collection:
|
|
|
|
raise NotScheduled(schedule_str)
|
|
|
|
raise NotScheduled(schedule_str)
|
|
|
|