Catch all exceptions in __init__

This commit is contained in:
Alexis Metaireau 2011-04-20 14:44:25 +02:00
commit 698686e1d4
2 changed files with 17 additions and 15 deletions

View file

@ -20,7 +20,9 @@ class Pelican(object):
"""
self.path = path or settings['PATH']
if not self.path:
raise Exception('you need to specify a path to search the docs on !')
raise Exception('you need to specify a path containing the content'
' (see pelican --help for more information)')
if self.path.endswith('/'):
self.path = path[:-1]
@ -132,20 +134,19 @@ def main():
module = __import__(module)
cls = getattr(module, cls_name)
pelican = cls(settings, args.path, args.theme, args.output, markup, args.keep)
if args.autoreload:
while True:
try:
if files_changed(pelican.path, pelican.markup):
pelican.run()
except KeyboardInterrupt:
break
else:
try:
try:
pelican = cls(settings, args.path, args.theme, args.output, markup, args.keep)
if args.autoreload:
while True:
try:
if files_changed(pelican.path, pelican.markup):
pelican.run()
except KeyboardInterrupt:
break
else:
pelican.run()
except Exception, e:
log.critical(str(e))
except Exception, e:
log.critical(str(e))
if __name__ == '__main__':

View file

@ -83,7 +83,8 @@ def init(level=None, logger=logging.getLogger(), handler=logging.StreamHandler()
fmt = Formatter()
handler.setFormatter(fmt)
logger.addHandler(handler)
if level: logger.setLevel(level)
if level:
logger.setLevel(level)
if __name__ == '__main__':