I have found myself wanting to schedule things hourly (morning shows on weekday, after midnight shows, saturday morning cartoons, box office movies in the evening) and the current strategy involves me writing a lot of yaml.
I have this code in util.py and it works but doesn't work when combined with range :( hoping someone can help me out or just take it over
elif run_time.startswith("myhourly_range"):
logger.error("In hourly range")
match = re.match("^([0-9]|0[0-9]|1[0-9]|2[0-3])-([0-9]|0[0-9]|1[0-9]|2[0-3])$", param)
if not match:
logger.error(f"Schedule Error: hourly_range {display} must be in the hour-hour format i.e. hourly_range(07-15)")
continue
hour_start = int(match.group(1))
hour_end = int(match.group(2))
if hour_start <= hour_end:
hours = list(range(hour_start, hour_end + 1))
else:
hours = list(range(hour_start, 24)) + list(range(0, hour_end + 1))
hourly_strings = [f"hourly({hour})" for hour in hours]
hour_range_string = ", ".join(hourly_strings)
range_collection = True
schedule_str += schedule_check(attribute, hour_range_string, current_time, run_hour, is_all=False)
all_check += 1