Commit ec96e49d authored by Matthieu Haefele's avatar Matthieu Haefele
Browse files

Merge branch 'dev-haefele' into 'master'

Fix #217 Erreur en l'absence de connexion internet : le programme est vide et...

Closes #217

See merge request !511
parents e4c85a30 184ad3dc
Pipeline #6062 passed with stages
in 32 seconds
......@@ -46,7 +46,12 @@ def get_indico_event_as_schedule(url, event):
from urllib.request import urlopen
import json
response = urlopen(url + '/export/timetable/' + str(event) + ".json").read()
try:
response = urlopen(url + '/export/timetable/' + str(event) + ".json").read()
except:
print("WARNING: indico content could not be fetched, no programme will be built. Offline ?")
return None
data = json.loads(response.decode('utf-8'))
schedule = {}
......@@ -216,8 +221,12 @@ class Schedule(Directive):
'for the indico_url "%s" .' % (self.name, self.options['indico_url']))
source = self.options['indico_url']
event = self.options['indico_event']
content = get_indico_event_as_schedule(source, event).split('\n')
self.state.nested_parse(StringList(content), len(content), sche)
content = get_indico_event_as_schedule(source, event)
if content != None: #we are online
content = content.split('\n')
self.state.nested_parse(StringList(content), len(content), sche)
else: # we are offline and nothing is fetched from indico
self.state.nested_parse(self.content, self.content_offset, sche)
else:
self.assert_has_content()
......
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