Added Error handling for recurring events
With the added Error handling, the stability of the recurring-events-parsing section has improved as well. This is handy when using non-supported iCalendars.
This commit is contained in:
		| @@ -46,6 +46,7 @@ def fetch_events(): | |||||||
|           else: |           else: | ||||||
|             events.begin = events.begin.to(timezone) |             events.begin = events.begin.to(timezone) | ||||||
|             events.end = events.end.to(timezone) |             events.end = events.end.to(timezone) | ||||||
|  |           try: | ||||||
|             rule = re.search('RRULE:(.+?)\n', event_str).group(0)[:-2] |             rule = re.search('RRULE:(.+?)\n', event_str).group(0)[:-2] | ||||||
|             if re.search('UNTIL=(.+?);', rule) and not re.search('UNTIL=(.+?)Z;', rule): |             if re.search('UNTIL=(.+?);', rule) and not re.search('UNTIL=(.+?)Z;', rule): | ||||||
|               rule = re.sub('UNTIL=(.+?);', 'UNTIL='+re.search('UNTIL=(.+?);', rule).group(0)[6:-1]+'T000000Z;', rule) |               rule = re.sub('UNTIL=(.+?);', 'UNTIL='+re.search('UNTIL=(.+?);', rule).group(0)[6:-1]+'T000000Z;', rule) | ||||||
| @@ -60,6 +61,9 @@ def fetch_events(): | |||||||
|                 upcoming_events.append(cc) |                 upcoming_events.append(cc) | ||||||
|                 #print("Added '{}' with new start at {}".format(cc.name, cc.begin.format('DD MMM YY'))) |                 #print("Added '{}' with new start at {}".format(cc.name, cc.begin.format('DD MMM YY'))) | ||||||
|  |  | ||||||
|  |           except Exception as e: | ||||||
|  |             print('Something went wrong while parsing recurring events') | ||||||
|  |             pass | ||||||
|  |  | ||||||
|   """Sort events according to their beginning date""" |   """Sort events according to their beginning date""" | ||||||
|   def sort_dates(event): |   def sort_dates(event): | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user