From 698686e1d432f09e2ed89a3cdbfd2d7c8fe40b09 Mon Sep 17 00:00:00 2001 From: Alexis Metaireau Date: Wed, 20 Apr 2011 14:44:25 +0200 Subject: [PATCH] Catch all exceptions in __init__ --- pelican/__init__.py | 29 +++++++++++++++-------------- pelican/log.py | 3 ++- 2 files changed, 17 insertions(+), 15 deletions(-) diff --git a/pelican/__init__.py b/pelican/__init__.py index 1b73fc97..497e5d0d 100755 --- a/pelican/__init__.py +++ b/pelican/__init__.py @@ -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__': diff --git a/pelican/log.py b/pelican/log.py index ebe1df5b..b895ad66 100644 --- a/pelican/log.py +++ b/pelican/log.py @@ -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__':