Improved error handling

This commit is contained in:
Maximilian Giller 2019-07-05 21:30:14 +02:00
parent 464f489ebd
commit fdb4331aec

View file

@ -102,6 +102,7 @@ class CalendarInterface (DataSourceInterface):
end = start + duration end = start + duration
occurrences = [] occurrences = []
try:
r_string=self.__add_timezoneawarness__(event.rrule) r_string=self.__add_timezoneawarness__(event.rrule)
rule=rrulestr(r_string,dtstart=event.begin_datetime) rule=rrulestr(r_string,dtstart=event.begin_datetime)
for occurrence in rule: for occurrence in rule:
@ -111,6 +112,9 @@ class CalendarInterface (DataSourceInterface):
if self.__is_onetime_in_range__(merged_event, start, duration): if self.__is_onetime_in_range__(merged_event, start, duration):
occurrences.append(merged_event) occurrences.append(merged_event)
return occurrences return occurrences
except Exception as ex:
print("\"is_repeating_in_range\" failed while processing: dtstart.tzinfo="+str(event.begin_datetime.tzinfo))
raise ex
def __merge_event_data__ (self, event, start = None): def __merge_event_data__ (self, event, start = None):
if start is not None: if start is not None:
@ -120,15 +124,16 @@ class CalendarInterface (DataSourceInterface):
return event return event
def __add_timezoneawarness__ (self, rrule): def __add_timezoneawarness__ (self, rrule):
"""UNTIL must be specified in UTC when DTSTART is timezone-aware (which it is)"""
if "UNTIL" not in rrule: if "UNTIL" not in rrule:
return rrule return rrule
timezone_str = "T000000Z" timezone_str = "T000000Z"
until_example = "UNTIL=YYYYMMDD" until_template = "UNTIL=YYYYMMDD"
until_index = rrule.index("UNTIL") until_index = rrule.index("UNTIL")
tz_index = until_index + len(until_example) tz_index = until_index + len(until_template)
if tz_index < 0 or tz_index >= len(rrule): if tz_index < 0 or tz_index >= len(rrule):
return rrule return rrule