Commit 1a8f2361 authored by Julian Rother's avatar Julian Rother
Browse files

Use scheduler to periodically update next meeting psa

parent b1fcaefe
...@@ -19,3 +19,4 @@ SQLITE_INIT_SCHEMA = True ...@@ -19,3 +19,4 @@ SQLITE_INIT_SCHEMA = True
SQLITE_INIT_DATA = False SQLITE_INIT_DATA = False
#LDAP_HOST = 'ldaps://rumo.fsmpi.rwth-aachen.de' #LDAP_HOST = 'ldaps://rumo.fsmpi.rwth-aachen.de'
#ICAL_URL = 'https://user:password@mail.fsmpi.rwth-aachen.de/SOGo/....ics'
...@@ -21,6 +21,7 @@ def get_next_meeting(): ...@@ -21,6 +21,7 @@ def get_next_meeting():
event = sorted(meetings, key=lambda e: e['DTSTART'].dt)[0] event = sorted(meetings, key=lambda e: e['DTSTART'].dt)[0]
return str(event['UID']), event['DTSTART'].dt.replace(tzinfo=None) return str(event['UID']), event['DTSTART'].dt.replace(tzinfo=None)
@sched_func(60*60)
def update_meeting(): def update_meeting():
try: try:
uid, start = get_next_meeting() uid, start = get_next_meeting()
......
...@@ -8,6 +8,7 @@ import sys ...@@ -8,6 +8,7 @@ import sys
import hashlib import hashlib
import random import random
import sched import sched
import time
app = Flask(__name__) app = Flask(__name__)
...@@ -19,6 +20,7 @@ app.add_template_global(timedelta, name='timedelta') ...@@ -19,6 +20,7 @@ app.add_template_global(timedelta, name='timedelta')
scheduler = sched.scheduler() scheduler = sched.scheduler()
def run_scheduler(): def run_scheduler():
time.sleep(1) # UWSGI does weird things on startup
while True: while True:
scheduler.run() scheduler.run()
...@@ -449,3 +451,5 @@ import feeds ...@@ -449,3 +451,5 @@ import feeds
import importer import importer
import schedule import schedule
import sorter import sorter
if 'ICAL_URL' in config:
import meetings
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment