1
0
Fork 0

better logging

This commit is contained in:
boyska 2017-05-05 17:12:38 +02:00
parent cbd585babe
commit 81ec2cef95
No known key found for this signature in database
GPG key ID: 7395DCAE58289CA9

View file

@ -50,7 +50,11 @@ def get_talk_data(talkname):
if not os.path.isfile(fname):
return None
with io.open(fname, encoding='utf8') as buf:
data = yaml.load(buf)
try:
data = yaml.load(buf)
except Exception as exc:
logging.exception("Syntax error reading %s; skipping", fname)
return None
if data is None:
return None
if 'title' not in data:
@ -60,13 +64,14 @@ def get_talk_data(talkname):
logging.warn("Talk <{}> has no `text` field".format(talkname))
data['text'] = ''
if 'duration' not in data:
logging.info("Talk <{}> has no `duration` field".format(talkname))
logging.info("Talk <{}> has no `duration` field (50min used)"
.format(talkname))
data['duration'] = 50
data['duration'] = int(data['duration'])
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.error("Talk <{}> has no `time` or `day`".format(talkname))
logging.warn("Talk <{}> has no `time` or `day`".format(talkname))
if 'time' in data:
timeparts = re.findall(r'\d+', str(data['time']))
if 4 > len(timeparts) > 0: