diff --git a/main.py b/main.py index c59f5a8..352f68b 100644 --- a/main.py +++ b/main.py @@ -20,9 +20,15 @@ def crawl(): # \____/\___/\__/ /_/ /_/\___/|__/|__/ \___/|___/\___/_/ /_/\__/____/ # Get events in the next year from RaPla - events = icalevents.events(url='https://rapla.dhbw-karlsruhe.de/rapla?page=ical&user=eisenbiegler&file=TINF19B4', - http=http, start=datetime.strptime('2010-01-01', '%Y-%m-%d'), - end=datetime.now() + timedelta(days=365)) + try: + events = icalevents.events( + url='https://rapla.dhbw-karlsruhe.de/rapla?page=ical&user=eisenbiegler&file=TINF19B4', + http=http, start=datetime.strptime('2010-01-01', '%Y-%m-%d'), + end=datetime.strptime((datetime.now() + timedelta(days=365)).strftime('%Y-%m-%d'), '%Y-%m-%d')) + except ValueError as error: + # Value error sometimes happens because of a problem with dateutil and timezones + print("Error fetching ical events. Terminating." + str(error.with_traceback())) + exit(1) # ______ __ __ __ __ __ __ ____ _____ ____ __ # / ____/__ / /_ / /___ _/ /____ _____/ /_ ____/ /___ _/ /_____ _ / __/________ ____ ___ / ___// __ \ / / @@ -146,7 +152,8 @@ def crawl(): # 2. If there is already a changeset for this event, is the latest known state that it is not deleted? # 3. If there is no changeset for it yet, we can't check the latest known state so we just set it to deleted # -> this basically can't ever happen with real data but it happened during testing and it doesn't hurt to let in in here - if uid not in list(x.uid for x in events) and (uid in changeDict.keys() and not changeDict[uid][3] or uid not in changeDict.keys()): + if uid not in list(x.uid for x in events) and ( + uid in changeDict.keys() and not changeDict[uid][3] or uid not in changeDict.keys()): # Only insert if there is no 'deleted' record yet deletedEvents.append(tuple([uid]))