diff --git a/docs/metadata/details/schedule.md b/docs/metadata/details/schedule.md index 8eee359c..7e2bd7ca 100644 --- a/docs/metadata/details/schedule.md +++ b/docs/metadata/details/schedule.md @@ -14,10 +14,10 @@ The scheduling options are: |:-------------|:-----------------------------------------------------------------------------------------------------------|:---------------------------------------------------|:-------------------------------------------------------------| | Hourly | Update only when the script is run in that hour or hour range | hourly(Hour of Day)
hourly(Start Hour-End Hour) | `hourly(17)`
`hourly(17-04)` | | Daily | Update once a day | daily | `daily` | -| Weekly | Update once a week on the specified days (For multiple days use a bar-separated (|) list | weekly(Days of Week) | `weekly(sunday)`
weekly(sunday|tuesday) | +| Weekly | Update once a week on the specified days (For multiple days, use a bar-separated (|) list)| weekly(Days of Week) | `weekly(sunday)`
weekly(sunday|tuesday) | | Monthly | Update once a month on the specified day | monthly(Day of Month) | `monthly(1)` | | Yearly | Update once a year on the specified day | yearly(MM/DD) | `yearly(01/30)` | -| Range | Updates whenever the date is within the range | range(MM/DD-MM/DD) | `range(12/01-12/31)` | +| Range | Updates whenever the date is within the range (For mulitple ranges, use a bar-separated (`\|`) list) | range(MM/DD-MM/DD) | `range(12/01-12/31)`
`range(8/01-8/15\|9/01-9/15)` | | Never | Never updates | never | `never` | | Non Existing | Updates if it doesn't exist | non_existing | `non_existing` | | All | Requires that all comma separated scheduling options inside its brackets be meet in order to run | all[Options] | `all[weekly(sunday), hourly(17)]` | diff --git a/modules/util.py b/modules/util.py index 994fea4f..c6725d8d 100644 --- a/modules/util.py +++ b/modules/util.py @@ -669,20 +669,23 @@ def schedule_check(attribute, data, current_time, run_hour, is_all=False): except ValueError: logger.error(f"Schedule Error: yearly {display} must be in the MM/DD format i.e. yearly(11/22)") 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) - if not match: - logger.error(f"Schedule Error: range {display} must be in the MM/DD-MM/DD format i.e. range(12/01-12/25)") - continue - 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_check, day_check = check_day(current_time.month, current_time.day) - check = datetime.strptime(f"{month_check}/{day_check}", "%m/%d") - start = datetime.strptime(f"{month_start}/{day_start}", "%m/%d") - end = datetime.strptime(f"{month_end}/{day_end}", "%m/%d") - range_collection = True - schedule_str += f"\nScheduled between {pretty_months[month_start]} {num2words(day_start, to='ordinal_num')} and {pretty_months[month_end]} {num2words(day_end, to='ordinal_num')}" - if start <= check <= end if start < end else (check <= end or check >= start): - all_check += 1 + ok_ranges = param.lower().split("|") + err = None + for ok_range in ok_ranges: + 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])$", ok_range) + if not match: + logger.error(f"Schedule Error: range {display} must be in the MM/DD-MM/DD format i.e. range(12/01-12/25)") + continue + 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_check, day_check = check_day(current_time.month, current_time.day) + check = datetime.strptime(f"{month_check}/{day_check}", "%m/%d") + start = datetime.strptime(f"{month_start}/{day_start}", "%m/%d") + end = datetime.strptime(f"{month_end}/{day_end}", "%m/%d") + range_collection = True + schedule_str += f"\nScheduled between {pretty_months[month_start]} {num2words(day_start, to='ordinal_num')} and {pretty_months[month_end]} {num2words(day_end, to='ordinal_num')}" + if start <= check <= end if start < end else (check <= end or check >= start): + all_check += 1 else: logger.error(f"Schedule Error: {display}") if is_all: