multiple ranges support

pull/1602/head
tyler 1 year ago
parent f47a7005cf
commit c8e55528b8

@ -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)<br>hourly(Start Hour-End Hour) | `hourly(17)`<br>`hourly(17-04)` | | Hourly | Update only when the script is run in that hour or hour range | hourly(Hour of Day)<br>hourly(Start Hour-End Hour) | `hourly(17)`<br>`hourly(17-04)` |
| Daily | Update once a day | daily | `daily` | | Daily | Update once a day | daily | `daily` |
| Weekly | Update once a week on the specified days (For multiple days use a bar-separated (<code>&#124;</code>) list | weekly(Days of Week) | `weekly(sunday)`<br><code>weekly(sunday&#124;tuesday)</code> | | Weekly | Update once a week on the specified days (For multiple days, use a bar-separated (<code>&#124;</code>) list)| weekly(Days of Week) | `weekly(sunday)`<br><code>weekly(sunday&#124;tuesday)</code> |
| Monthly | Update once a month on the specified day | monthly(Day of Month) | `monthly(1)` | | 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)` | | 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)`<br>`range(8/01-8/15\|9/01-9/15)` |
| Never | Never updates | never | `never` | | Never | Never updates | never | `never` |
| Non Existing | Updates if it doesn't exist | non_existing | `non_existing` | | 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)]` | | All | Requires that all comma separated scheduling options inside its brackets be meet in order to run | all[Options] | `all[weekly(sunday), hourly(17)]` |

@ -669,7 +669,10 @@ def schedule_check(attribute, data, current_time, run_hour, is_all=False):
except ValueError: except ValueError:
logger.error(f"Schedule Error: yearly {display} must be in the MM/DD format i.e. yearly(11/22)") logger.error(f"Schedule Error: yearly {display} 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) 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: 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)") 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

Loading…
Cancel
Save