🐛 Preventing error in case of a misbehaving dateutil / timezone
This commit is contained in:
parent
430769bd33
commit
a8045d65c4
15
main.py
15
main.py
|
@ -20,9 +20,15 @@ def crawl():
|
||||||
# \____/\___/\__/ /_/ /_/\___/|__/|__/ \___/|___/\___/_/ /_/\__/____/
|
# \____/\___/\__/ /_/ /_/\___/|__/|__/ \___/|___/\___/_/ /_/\__/____/
|
||||||
|
|
||||||
# Get events in the next year from RaPla
|
# Get events in the next year from RaPla
|
||||||
events = icalevents.events(url='https://rapla.dhbw-karlsruhe.de/rapla?page=ical&user=eisenbiegler&file=TINF19B4',
|
try:
|
||||||
http=http, start=datetime.strptime('2010-01-01', '%Y-%m-%d'),
|
events = icalevents.events(
|
||||||
end=datetime.now() + timedelta(days=365))
|
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?
|
# 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
|
# 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
|
# -> 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
|
# Only insert if there is no 'deleted' record yet
|
||||||
deletedEvents.append(tuple([uid]))
|
deletedEvents.append(tuple([uid]))
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user