1
0
Fork 0

errori un po piu chiari

This commit is contained in:
boyska 2017-05-22 11:13:25 +02:00
parent 01827360bc
commit b859aa8d8f
No known key found for this signature in database
GPG key ID: 7395DCAE58289CA9

View file

@ -103,50 +103,54 @@ def get_talk_data(talkname):
return None
if data is None:
return None
if 'title' not in data:
logging.warn("Talk <{}> has no `title` field".format(talkname))
data['title'] = talkname
if 'text' not in data:
logging.warn("Talk <{}> has no `text` field".format(talkname))
data['text'] = ''
if 'duration' not in data:
logging.info("Talk <{}> has no `duration` field (50min used)"
.format(talkname))
data['duration'] = 50
data['duration'] = int(data['duration'])
if data['duration'] < GRID_STEP:
logging.info("Talk <{}> lasts only {} minutes; changing to {}"
.format(talkname, data['duration'], GRID_STEP))
data['duration'] = GRID_STEP
if 'links' not in data or not data['links']:
data['links'] = []
if 'contacts' not in data or not data['contacts']:
data['contacts'] = []
if 'needs' not in data or not data['needs']:
data['needs'] = []
if 'room' not in data:
logging.warn("Talk <{}> has no `room` field".format(talkname))
if 'time' not in data or 'day' not in data:
logging.warn("Talk <{}> has no `time` or `day`".format(talkname))
if 'time' in data:
del data['time']
try:
if 'title' not in data:
logging.warn("Talk <{}> has no `title` field".format(talkname))
data['title'] = talkname
if 'text' not in data:
logging.warn("Talk <{}> has no `text` field".format(talkname))
data['text'] = ''
if 'duration' not in data:
logging.info("Talk <{}> has no `duration` field (50min used)"
.format(talkname))
data['duration'] = 50
data['duration'] = int(data['duration'])
if data['duration'] < GRID_STEP:
logging.info("Talk <{}> lasts only {} minutes; changing to {}"
.format(talkname, data['duration'], GRID_STEP))
data['duration'] = GRID_STEP
if 'links' not in data or not data['links']:
data['links'] = []
if 'contacts' not in data or not data['contacts']:
data['contacts'] = []
if 'needs' not in data or not data['needs']:
data['needs'] = []
if 'room' not in data:
logging.warn("Talk <{}> has no `room` field".format(talkname))
if 'time' not in data or 'day' not in data:
logging.warn("Talk <{}> has no `time` or `day`".format(talkname))
if 'time' in data:
del data['time']
if 'day' in data:
del data['day']
if 'day' in data:
del data['day']
if 'day' in data:
data['day'] = get_global_data()['startdate'] + datetime.timedelta(days=data['day'])
if 'time' in data and 'day' in data:
timeparts = re.findall(r'\d+', str(data['time']))
if 4 > len(timeparts) > 0:
timeparts = [int(p) for p in timeparts]
data['time'] = datetime.datetime.combine(data['day'],
datetime.time(*timeparts))
else:
logging.error("Talk <{}> has malformed `time`".format(talkname))
data['id'] = talkname
resdir = os.path.join(TALKS_PATH, talkname, TALK_ATTACHMENT_PATH)
if os.path.isdir(resdir) and os.listdir(resdir):
data['resources'] = resdir
return data
data['day'] = get_global_data()['startdate'] + datetime.timedelta(days=data['day'])
if 'time' in data and 'day' in data:
timeparts = re.findall(r'\d+', str(data['time']))
if 4 > len(timeparts) > 0:
timeparts = [int(p) for p in timeparts]
data['time'] = datetime.datetime.combine(data['day'],
datetime.time(*timeparts))
else:
logging.error("Talk <{}> has malformed `time`".format(talkname))
data['id'] = talkname
resdir = os.path.join(TALKS_PATH, talkname, TALK_ATTACHMENT_PATH)
if os.path.isdir(resdir) and os.listdir(resdir):
data['resources'] = resdir
return data
except:
logging.exception("Error on talk %s", talkname)
raise
jinja_env = jinja2.Environment(
@ -264,13 +268,16 @@ class TalkGridDirective(Directive):
def talks_to_ics():
content = u'BEGIN:VCALENDAR\nVERSION:2.0\nPRODID:pelican\n'
for t in all_talks():
content += talk_to_ics(t)
try:
content += talk_to_ics(t)
except:
logging.exception("Error producing calendar for talk %s", t['id'])
content += 'END:VCALENDAR\n'
return content
def talk_to_ics(talk):
if 'time' not in talk or 'duration' not in talk:
if 'time' not in talk or 'duration' not in talk or 'room' not in talk:
return ''
start = talk['time']
end = start + datetime.timedelta(minutes=talk['duration'])